2015-07-17 4 views
0

Когда я нажимаю на уведомление от Urban Airship, он всегда запускает мою активность запуска (LoginActivity), но должен начинаться с AboutActivity.Городской дирижабль. PendingIntent всегда запускает активность запуска.

<activity android:name=".activity.LoginActivity" 
    android:theme="@android:style/Theme.Black.NoTitleBar" 
    android:screenOrientation="portrait" 
    android:windowSoftInputMode="stateVisible"> 

    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity> 

<activity android:name=".activity.AboutActivity" 
    android:theme="@android:style/Theme.Black.NoTitleBar" 
    android:screenOrientation="portrait"/> 

класс IntentReceiver:

public class IntentReceiver extends BaseIntentReceiver { 

private static final String TAG = "IntentReceiver"; 

@Override 
protected void onChannelRegistrationSucceeded(Context context, String channelId) { 
    Log.e(TAG, "Channel registration updated. Channel Id:" + channelId + "."); 
} 

@Override 
protected void onChannelRegistrationFailed(Context context) { 
    Log.e(TAG, "Channel registration failed."); 
} 

@Override 
protected void onPushReceived(Context context, PushMessage message, int notificationId) { 

} 

@Override 
protected void onBackgroundPushReceived(Context context, PushMessage message) { 
    Log.e(TAG, "Received background push message: " + message); 
} 

@Override 
protected boolean onNotificationOpened(Context context, PushMessage message, int notificationId) { 

    Bundle bundle = message.getPushBundle(); 
    if(bundle.containsKey("EEID") && bundle.containsKey("DATE") && bundle.containsKey("JOB")){ 

     Intent intent = new Intent(context, AboutActivity.class); 
     intent.putExtra(Consts.EXTRA_EMPLOYEE_ID, bundle.getString("EEID")); 
     intent.putExtra(Consts.EXTRA_DATE, bundle.getString("DATE")); 
     intent.putExtra(Consts.EXTRA_JOB_ID, bundle.getString("JOB")); 
     intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); 
     PendingIntent.getActivity(context, 0, intent, 0); 
    } 

    // Return false to let UA handle launching the launch activity 
    return false; 
} 

Что может быть проблема? Заранее спасибо.

ответ

0

линии:

// Return false to let UA handle launching the launch activity 
return false; 

Если вы возвращаете верно, уведомит Urban дирижабль SDK, что толчок был обработан и не автоматический запуск ракеты-носителя активности.

Кроме того, я думаю, что вы хотели следующий:

@Override 
protected boolean onNotificationOpened(Context context, PushMessage message, int notificationId) { 

    Bundle bundle = message.getPushBundle(); 
    if(bundle.containsKey("EEID") && bundle.containsKey("DATE") && bundle.containsKey("JOB")){ 
     Intent intent = new Intent(context, AboutActivity.class); 
     intent.putExtra(Consts.EXTRA_EMPLOYEE_ID, bundle.getString("EEID")); 
     intent.putExtra(Consts.EXTRA_DATE, bundle.getString("DATE")); 
     intent.putExtra(Consts.EXTRA_JOB_ID, bundle.getString("JOB")); 
     intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); 
     context.startActivity(intent); 

     // Return true so Urban Airship does not auto start the activity 
     return true; 
    } else { 
     return false; 
    } 
} 
+0

Спасибо большое! Оно работает. – anivaler

1

Во-первых, если вы вернете false, UA запустит операцию запуска в вашем случае LoginActivity. Используйте return true;

@Override 
protected boolean onNotificationOpened(Context context, PushMessage message, int notificationId) { 
    .... 
    return true; 
} 

Во-вторых, вы создали pendingIntent, но он не используется. Обратитесь к Starting Activity from BroadcastReceiver за то, что вы зашли на эту страницу с вашего BroadcastReceiver.

Смежные вопросы