Android Question How to auto start my app on android 10?

fash866

Member
Licensed User
Longtime User
Hi, I can't start my app on android 10 from the service.(It's ok on the android 7.)
I found a way like this :
B4X:
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
So i can see my app's notifaction bar afer the system reboot , but i dont know how to start activity from the notifaction .
I am try this code but its not run:
B4X:
Sub Service_Start (StartingIntent As Intent)
    Log("Service started !")
    Dim in As Intent
    
    in.Initialize(in.ACTION_VIEW, "package:my.package.app")
    StartActivity(in)
    'Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub
 

fash866

Member
Licensed User
Longtime User
B4X:
Intent intent = new Intent(this, ScopedStorageActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
        REQ_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(this, Constants.CHANNEL_ID)
        .setSmallIcon(R.drawable.ic_launcher_foreground)
        .setContentTitle("Incoming call")
        .setContentText("(919) 555-1234")
        .setPriority(NotificationCompat.PRIORITY_HIGH)
        .setCategory(NotificationCompat.CATEGORY_ALARM)
        //Send notice to start Activity
        .setFullScreenIntent(pendingIntent, true)
        .build();
NotificationManager manager = getSystemService(NotificationManager.class);
manager.notify(10, notification);
 
Upvote 0
Top