Download SDK Sample Project

This Android SDK integration guide uses Fragments.

1. Extend your Main activity from the FragmentActivity class and implement PushEventListener interface:

public class PushFragmentActivity extends FragmentActivity implements PushEventListener

2. In onCreate function call PushFragment.init(this);

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Init Pushwoosh fragment PushFragment.init(this);

3. In onNewIntent function call PushFragment.onNewIntent(this, intent);

@Override public void onNewIntent(Intent intent) { super.onNewIntent(intent); //Check if we've got new intent with a push notification PushFragment.onNewIntent(this, intent); }

4. Implement callbacks as per PushEventListener interface

public void doOnRegistered(String registrationId) { mGeneralStatus.setText(registrationId); } public void doOnRegisteredError(String errorId) { mGeneralStatus.setText(errorId); } public void doOnUnregistered(final String message) { mGeneralStatus.setText(message); } public void doOnUnregisteredError(String errorId) { mGeneralStatus.setText(errorId); } public void doOnMessageReceive(String message) { mGeneralStatus.setText(message); }

5. In AndroidManifest.xml manifest add the following lines under application tag. The GCM Project Number is a number, but make sure you prefix it with the letter "A".
Example:
<meta-data android:name="PW_APPID" android:value="4F0C807E51EC77.93591449" /> <meta-data android:name="PW_PROJECT_ID" android:value="A60756016005" />

Where:
PW_APPID is the Pushwoosh Application Code and PW_PROJECT_ID – is the Project Number you receive from Google Locate your Project Number prefixed with A.

(See more: http://developer.android.com/guide/google/gcm/index.html and http://developer.android.com/guide/google/gcm/gs.html)

`PW_PROJECT_ID` value is a number but make sure you prefix it with the letter **“A”** as in the example above.
**6.** In the AndroidManifest.xml make the following changes for this activity. Replace PACKAGE_NAME with the package name for your application.

<activity android:name="PushFragmentActivity" android:launchMode="singleTop" android:label="@string/app_name"> <intent-filter> <action android:name="PACKAGE_NAME.MESSAGE"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity>

7. Add the following changes in your AndroidManifest.xml under manifest tag. Replace PACKAGE_NAME with the package name for your application.

You can find your package name in the AndroidManifest.xml under the manifest tag in the very top of the file.
**READ_PHONE_STATE** permission: The SDK uses this permission to get DeviceId property of the device if ANDROID_ID is not available. You can omit this permission in your APK. However if ANDROID_ID will not be available, features like AppGroups or cross-application user targeting will not work for this device.

GET_ACCOUNTS permission: GCM requires a Google account if you target Androids lower than 4.0.4

**8.** Add the following changes in your AndroidManifest.xml under **application** tag. Replace PACKAGE_NAME with the package name for your application.
You can find your package name in the AndroidManifest.xml under the manifest tag in the very top of the file.
If you need to handle custom notifications from your server, you should create a class extended from **com.arellomobile.android.push.PushGCMIntentService**, and include this custom intent service under the **“PW_PUSH_SERVICE”** tag in your manifest file. **Example:** In your manifest you have to substitute the
with
That’s it!