标签:
复制 libs/armeabi/libjpush1xy.so 到工程 libs/armeabi 目录下
如果您的项目有 libs/armeabi-v7a 这个目录,请把armeabi 的so文件 也复制一份到这个目录。 |
根据 SDK 压缩包里的 AndroidManifest.xml 样例文件,来配置应用程序项目的 AndroidManifest.xml 。
主要步骤为:
权限配置: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Your Package" android:versionCode="100" android:versionName="1.0.0" > <!-- Required --> <permission android:name="Your Package.permission.JPUSH_MESSAGE" android:protectionLevel="signature" /> <!-- Required --> <uses-permission android:name="You Package.permission.JPUSH_MESSAGE" /> <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <!--since 1.6.0 --> <!-- Optional. Required for location feature --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> 应用包名及appkey替换: <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:name="Your Application"> <!-- Required --> <service android:name="cn.jpush.android.service.PushService" android:enabled="true" android:exported="false" > <intent-filter> <action android:name="cn.jpush.android.intent.REGISTER" /> <action android:name="cn.jpush.android.intent.REPORT" /> <action android:name="cn.jpush.android.intent.PushService" /> <action android:name="cn.jpush.android.intent.PUSH_TIME" /> </intent-filter> </service> <!-- Required --> <receiver android:name="cn.jpush.android.service.PushReceiver" android:enabled="true" > <intent-filter android:priority="1000"> <!--since 1.3.5 --> <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!--since 1.3.5 --> <category android:name="Your Package" /> <!--since 1.3.5 --> </intent-filter> <!--since 1.3.5 --> <intent-filter> <action android:name="android.intent.action.USER_PRESENT" /> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED" /> <action android:name="android.intent.action.PACKAGE_REMOVED" /> <data android:scheme="package" /> </intent-filter> </receiver> <!-- Required SDK核心功能--> <activity android:name="cn.jpush.android.ui.PushActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="orientation|keyboardHidden" > <intent-filter> <action android:name="cn.jpush.android.ui.PushActivity" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="Your Package" /> </intent-filter> </activity> <!-- Required SDK核心功能--> <service android:name="cn.jpush.android.service.DownloadService" android:enabled="true" android:exported="false" > </service> <!-- Required SDK核心功能--> <receiver android:name="cn.jpush.android.service.AlarmReceiver" /> <!-- Required. For publish channel feature --> <!-- JPUSH_CHANNEL 是为了方便开发者统计APK分发渠道。--> <!-- 例如: --> <!-- 发到 Google Play 的APK可以设置为 google-play; --> <!-- 发到其他市场的 APK 可以设置为 xxx-market。 --> <!-- 目前这个渠道统计功能的报表还未开放。--> <meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/> <!-- Required. AppKey copied from Portal --> <meta-data android:name="JPUSH_APPKEY" android:value="Your AppKey"/> </application> </manifest>
JPush SDK 提供的 API 接口,都主要集中在 cn.jpush.android.api.JPushInterface 类里。
public static void init(Context context) |
// You can enable debug mode in developing state. You should close debug mode when release. public static void setDebugMode( boolean debugEnalbed) |
public
class
ExampleApplication
extends
Application {
@Override
public
void
onCreate() {
super
.onCreate();
JPushInterface.setDebugMode(
true
);
JPushInterface.init(
this
);
}
}
如图所示,客户端启动分为 4 步:
标签:
原文地址:http://www.cnblogs.com/jinglecode/p/4351296.html