以下是我的問題:Android:在開放通知推送後恢復應用程序
我有一個包含3個活動的應用程序。
-SplashscreenActivity(發射器 - 主)
-LoginActivity
-HomeActivity
--application殺: - 正常流程
- 當我運行應用程序儀表板圖標,我經歷了飛濺,(我登錄),並在家裏。 如果我把應用程序放在後臺,並且通過儀表板圖標提出,我回到家中。一切正常。
--application殺死: - 然而,爲了下面的處理:
- 我得到的推送通知。我通過這個推動來運行應用程序,我經歷了一次飛濺,然後回到家中。 但是,如果我把應用程序放在背景中,並且我通過儀表板圖標來提高它,那麼我會再次系統地通過飛濺。這是問題!
這裏是我的manifest.xml(EDITED)
<activity
android:name="my.package.SplashscreenActivity"
android:label="@string/app_name"
android:noHistory="false"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="my.package.LoginActivity"
android:label="@string/app_name"
android:noHistory="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
</activity>
<activity
android:name="my.package.HomeActivity"
android:label="@string/app_name"
android:noHistory="false"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
</activity>
這裏是我的推送通知廣播接收器(sendNotificationMethod)
private void sendNotification(String message, String title, int count, String type, long threadId)
{
Activity m_activity;
if (App.getInstance().m_currentActivity != null && App.getInstance().isOnPause())
m_activity = App.getInstance().m_currentActivity;
else
m_activity = null;
PendingIntent pendingIntent = null;
Intent intent = null;
if (m_activity != null)
{
intent = new Intent(this, m_activity.getClass());
intent.putExtra("type", type);
intent.setData((Uri.parse("foobar://" + SystemClock.elapsedRealtime())));
pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
}
else
{
PackageManager pm = getPackageManager();
intent = pm.getLaunchIntentForPackage("my.package");
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("type", type);
pendingIntent = PendingIntent.getActivity(App.getInstance(), 0, intent, 0);
}
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.logo_push_lolilol)
.setColor(App.getInstance().getResources().getColor(R.color.colorPrimary))
.setContentTitle(title)
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(message));
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify((int)threadId, notificationBuilder.build());
}
你有 「解決」?
預先感謝您。
刪除此'機器人:launchMode = 「singleTop」'。 –
@DheerubhaiBansal它不會改變任何東西。 – museehomme