0

我正在開發我想要集成GCM的小型Android應用程序。我使用了一個模塊,工作正常。唯一的問題是,當我的應用程序是打開的,如果我點擊通知它重新啓動我不想要的應用程序..我想要的,如果應用程序已經運行,然後只顯示運行窗口,如果應用程序關閉,然後啓動應用程序... 在我的的onMessage模塊代碼收到看起來像Gcm或C2DM應用程序啓動問題。(Titanium android)

int icon = 0x7f020000; 

    CharSequence tickerText = new String("app anme: " + hashdata.get("messages")); 
    long when = System.currentTimeMillis(); 

    CharSequence contentTitle = "app name"; 
    CharSequence contentText = new String(" " + hashdata.get("messages")); 

    Intent notificationIntent = new Intent(this, GCMIntentService.class); 

    Intent launcherintent = new Intent("android.intent.action.MAIN"); 
    launcherintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); 

    launcherintent.setComponent(ComponentName.unflattenFromString("com.example/com.example.ExampleActivity")); 
    launcherintent.addCategory("android.intent.category.LAUNCHER"); 

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, launcherintent, 0); 

    Notification notification = new Notification(icon, tickerText, when); 

    notification.defaults = Notification.DEFAULT_ALL; 
    notification.flags = Notification.FLAG_AUTO_CANCEL; 
    notification.setLatestEventInfo(context, contentTitle, contentText,contentIntent); 
    String ns = Context.NOTIFICATION_SERVICE; 
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); 
    mNotificationManager.notify(1, notification); 

如果應用程序關閉我的模塊是工作的罰款。但重新啓動應用程序,它已經運行預計不......需要幫助.....謝謝...........

回答