Is there any possibility to open Notifications Menu in my app? I'm looking for solution similar to one below that opens System Settings side bar:
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
I've found solution, looks like sample below does the work. However I couldn't find any documentation about com.android.tv.NOTIFICATIONS_PANEL action.
Intent notificationIntent = new Intent("com.android.tv.NOTIFICATIONS_PANEL");
startActivity(notificationIntent);
I think you may want to try using toasts or notification-android-tv.
Also, do take note that:
notification will appear just as recommendations and not as
"notification"
For further info, you can refer to this SO post.
I am trying to launch an SMS app (Messenger/Hangouts) from my app. But the UI transition is not as expected. On launch, my app moves to the background and SMS app is launched from below the screen and this transition is slow and very much visible to the user.
I want the transition to be as fast as possible without showing any animation. I tried overridePendingTransition(0,0) and setting the Intent flag (FLAG_ACTIVITY_NO_ANIMATION), still does not help.
What should I be doing to acheive this?
This snippet of code works fine for me:
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setData(Uri.parse("sms:"));
overridePendingTransition(0,0);
startActivity(sendIntent);
Please paste the relevant code you have used for the same if the above does not work and I can look into it. Hope this helps!
Is it possible to open status bar notification from code? I already tried checking NotificationManager but found only methods that close current notifications. Any suggestion would be appreciated.
For anyone wondering it's possible to open if you provide package name:
Intent i = new Intent();
i.setPackage(sbn.getPackageName());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
I cant find any refrence to call the Intent screen "Choose screen lock".
Cant find anything?
Any idea?
You can call action DevicePolicyManager.SET_NEW_PASSWORD to send user to lock screen settings fragment (firstly he will have to type current password/pattern for secure lock types):
Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
startActivity(intent);
There is none. You can view all possible Intents in android's source code: https://github.com/android/platform_packages_apps_settings/blob/master/AndroidManifest.xml
EDIT:
It turns out that this had been added in Version 2.2 of Android.
Please ee pleczko's answer below.
Before Android 2.2 there is no intent to do this.
I have my app running in the background and I want the app to be shown on the top(launched) of the android phone when the code below is ran. (I know the code is ran for sure)
This seems like a simple thing but I spent a couple hours on this site and everyone seems to be suggesting something like this:
Intent intent = new Intent(myActivity.this, myActivity.class);
startActivity(intent);
However, it is not bringing the app to the front and launching it.
I got it to work from a PendingIntent launched from a notification. Which I done by the code below. But I want the app to launch by itself without the user clicking on the notification.
Intent intent = new Intent(myActivity.this, myActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, REQUEST_CODE, intent, 0);
notification.setLatestEventInfo(this, "title", "msg", contentIntent);
I also tried:
Intent intent = new Intent("android.intent.action.MAIN");
startActivity(intent);
and flagging the intent:
intent.setFlags(Intent.FLAG_FROM_BACKGROUND);
intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
But doesn't seem to do anything, any help appreciated.
You should be able to call your own application like this:
Intent intent = new Intent("android.intent.category.LAUNCHER");
intent.setClassName("com.your.package", "com.your.package.MainActivity");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Edit: Forgot to add intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
From what I understand, you want a service that is running in the background and on a certain event, you want your application's activity to come in front i.e. on the users current screen whatever he is doing. It is not advisable to let a background service launch an application without a user's action. The android developer website says
A status bar notification should be used for any case in which a
background service needs to alert the user about an event that
requires a response. A background service should never launch an
activity on its own in order to receive user interaction. The service
should instead create a status bar notification that will launch the
activity when selected by the user.
Hence, do not try to make it launch on its own.
I An not behind my laptop atm so I am nog sure, but I think you have toe pass a context object hand then do context.startactivity(intent);
Sorry for not wel formated I am at my phone atm
Hope It helps
I am clutching at straws here, but you wrote:
MyActivity is launched first, then I either navigate to another app or just hit the home screen to have my app running in the background.
So the situation is that your original Activity is NOT running in the background, when you pressed HOME it might well could have been stopped and destroyed. Your background task remained orphan and MyActivity.this is null at this point.
Try and test what does Log.i(TAG,MyActivity.this); print into LogCat.
I ended up using a pending intent and instead of stright up trying to use a intent.
Something like this: seems a lot more simple.
Intent.send(this, 0, intent);
Thanks.
Also, I’ve seen since compileSdkVersion 29 it's not possible, unless a few restrictions:
The activity started very recently.
The app called finish() very recently.
Through a PendingIntent, but only after a few seconds after the notification was sent.
The app has been granted the SYSTEM_ALERT_WINDOW permission by the user.
...
https://developer.android.com/guide/components/activities/background-starts