есть ли способ разбудить уже запущенное приложение из панели уведомлений после сообщения c2dm? У меня есть это приложение, зарегистрированное на серверах c2dm, которое получает push-уведомления с моего сервера для выполнения некоторой обработки. поэтому после того, как я получаю сообщение c2dm с моего сервера, он отображает пользователю уведомление в строке состояния, пользователь расширяет уведомления и нажимает на мое приложение, вызывает его.
все хорошо, но если это приложение уже было запущено раньше (глядело по значку), это загрузило бы еще один экземпляр моего приложения в память. также некоторые вещи терпят крах в нем. я уже изменил android:launchMode="singleTop"
во всех своих действиях, я пытался использовать intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
в своем уведомлении, но безуспешно. у меня всегда работает 2 приложения.
любая помощь приветствуется
вот моя статическая функция, которую я использую для создания уведомления после получения сообщения c2dm:
public static void notifyStart(Context context, String notificationText) {
//notification
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
int icon = R.drawable.icon_notify;
CharSequence tickerText = notificationText;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
notification.ledARGB = 0xff00ff00;
notification.ledOnMS = 400;
notification.ledOffMS = 400;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.defaults |= Notification.DEFAULT_SOUND;
CharSequence contentTitle = "App Name";
CharSequence contentText = notificationText;
Intent notificationIntent = new Intent(context, home.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(1350, notification);
}
и вот моя домашняя деятельность:
<activity android:name=".home"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
launchMode
изsingleInstance
? developer.android.com/guide/topics/manifest/ а> - person james   schedule 09.03.2011