OnMessage i want to open Google Play android

前端 未结 1 1497
难免孤独
难免孤独 2021-01-25 23:59

I get notification from GCM, When i get notification, i want to show google play to install app.

Im trying like this

    NotificationManager notification         


        
1条回答
  •  北荒
    北荒 (楼主)
    2021-01-26 00:55

    I have tested this code in my mobile and it is working

    AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            int sb2value = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
            NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notification = new Notification(R.drawable.ic_launcher, "Testomg", System.currentTimeMillis() + 5000);
    
            Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
            notificationIntent.setData(Uri.parse("market://details?id=com.karya.kot"));
            notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            PendingIntent intent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
            notification.setLatestEventInfo(getApplicationContext(), "Google Play", "Download app", intent);
    
            notification.flags |= Notification.FLAG_AUTO_CANCEL;
            notificationManager.notify(0, notification);
    

    0 讨论(0)
提交回复
热议问题