2014-07-18 84 views
0

我在我的应用程序中遇到了一个非常奇怪的问题。我使用通知通过服务将我的应用从后台移到前台。我的问题是,当我从PC安装apk文件(通过Eclipse或通过将apk复制到我的设备),通知完美地工作。当我从Play商店安装我的应用程序(相同的apk),并且用户点击通知时,它会启动一个新的实例EntryScreen,并且不作为启动器图标工作!任何想法为什么发生这种情况?从Play商店安装时,应用程序无法正常工作

在此先感谢!

服务代码:

@Override 
public int onStartCommand(Intent intent, int flags, int startId) { 

    Intent intentForeground = new Intent(getApplicationContext(),EntryScreen.class); 

    intentForeground.setAction(Intent.ACTION_MAIN); 

    intentForeground.addCategory(Intent.CATEGORY_LAUNCHER); 

    PendingIntent pendint = PendingIntent.getActivity(getApplicationContext(), 0, intentForeground, PendingIntent.FLAG_ONE_SHOT); 

    NotificationCompat.Builder mBuilder = 
      new NotificationCompat.Builder(this) 
      .setSmallIcon(R.drawable.final_driver_notification_icon) 
      .setContentTitle("...") 
      .setContentText("...") 
      .setContentIntent(pendint) 
      .setTicker("..."); 

    Notification notif = mBuilder.build(); 

    int notID = 1; 

    startForeground(notID, notif); 


    return super.onStartCommand(intent, flags, startId); 
} 

回答

0

的问题,也许是在清单中,您需要在您的活动,并发出通知打开添加launchMode。例如,如果您的活动是EntryScreen.class,请参阅清单的代码。

<activity 
      android:name=".EntryScreen" 
      android:launchMode="singleTask"/> 
+0

我也尝试过,它并没有帮助。但如果这就是为什么当我从eclipse安装应用程序它的作品完美,并从Play商店不是? – user3734693

+0

呃..穿,尝试使用com.google.android.gms.gcm.GoogleCloudMessaging图书馆从谷歌播放服务全局gcm从罐 – Giancarlo

+0

当我删除gcm.jar如何扩展GCMBaseIntentService? – user3734693

相关问题