Android -> Status bar state changed - android

Is there a possibily within Android to get the state of the status bar, especially a new notification was added to it?
It need this to start an activity if something happend in the status bar. I don't mean the "Status bar windows".
Maybe I can use an IntentFilter like :
IntentFilter statusBarIntentFilter = new IntentFilter(android.bla.bla.ACTION_STATUSBAR_STATE_CHANGED);
Thank you so far in advanced!
BR

Is there a possibily within Android to get the state of the status bar, especially a new notification was added to it?
No, sorry. You cannot spy on other applications' notifications from the Android SDK.

Is there a possibily within Android to get the state of the status bar, especially a new notification was added to it?
You can listen for status bar notifications by using AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED.
Here is a StackOverflow answer on this subject, and here is a working example I put together based upon that answer. I actually put that example together because an application was, essentially, spamming my wife's notification bar with advertisements and there was no clear way of telling who the offending application was.

Related

Opening Android Notifications programmatically

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.

Show *only* a toast (no UI) after sharing text into an app?

I'm a starting Android developer and would like to know how to achieve this:
1# User is using e.g. Chrome
2# User wants to share the page (meaning: the URL, which is text) into an app
3# User chooses the app from the share menu
4# The app shows only a small notification on top of Chrome (current foreground app, which is the sender of the intent)
So the app would receive the intent from Chrome and do something with it, but wouldn't change the foreground app. It would stay in the background and show only a very small notification to the user that the sharing of the URL into this app actually succeeded. Toast or something like that.
This is basically the way for instance Pocket handles sharing into it.
How can I achieve this? IntentService? I cannot seem to find the correct answer to this. Theme.NoDisplay, Intent, IntentService – I cannot figure out the correct way since I'm not too familiar with Android yet.
Thank you a lot in advance!
Use the NoDisplay theme (update activity declaration in manifest) in the activity that does your sharing work as follows:
android:theme="#android:style/Theme.NoDisplay"
This will prevent the activity from being displayed.
Then once the activity starts, do your sharing task, display the Toast and call finish()
finish your activity onResume(). It will not shows any of Your Activity.
You can do like this:
protected void onResume() {
super.onResume();
finish();
}

How make a Android application that can't be closed

I'm developing an Android app for a company where those who will use it are the employees, for this reason the company asked me to develop an application that the user can not close, because if he will not use the smartphone for other purposes, but for this I need the Android native buttons do not interfere with the application.
I've deactivated the button to go back and put the application as Home.
#Override
     public void onBackPressed () {
         super.onBackPressed ();
     }
...
<category android: name = "android.intent.category.HOME" />
However if the user clicks the button that displays open applications, it can exit the application.
I researched a lot before creating resolve this question and realized several attempts to solve this problem.
One. I tried to create the same behavior as the MX Player has, when you use the lock to see a video, the MX Player is always on top of everything, leaving the user to see and click others places. However using this behavior does not i cant see My Dialogs nor Popup and also can not apply a thema, as in my case is not simply an activity is the entire application.
Reference links of my attempt
How to disable Home and other system buttons in Android?
http://www.piwai.info/chatheads-basics/
If anyone knows how to use that behavior MX Player, or if anyone knows any more how to make the user can not close the application, please help me, I know it's not just me who have this problem.
Any help is welcome!
My API is 16 - Android-4.1
Are your target devices rooted? If so, this article goes through the steps to make this possible. What you specifically ask about can be done by modifying the build.prop file to include the following line: qemu.hw.mainkeys=1. This will stop the soft-key navigation bar from ever showing up.
If the device you're running isn't rooted, I don't think that it's possible to do what you're asking.
The best way i found to the user can't access others apps, was to make a service that check which is the top activity, if don't is my then reopen my app.
ActivityManager manager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> runningTasks = manager.getRunningTasks(1);
if (runningTasks != null && runningTasks.size() > 0) {
ComponentName topActivity = runningTasks.get(0).topActivity;
if (!topActivity.getPackageName().startsWith("com.mypackage.")) {
Log.i("Top Activity", topActivity.getPackageName());
if (LocalCache.getInstance().isForceHome()) {
Intent intent = new Intent(HomeService.this, AuthLoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
handler.postDelayed(this, 500);
}
Old question, but I'm facing exactly same situation:
In-house App
Can't be close
I'm going to set App as a Launcher, and block top-dowm swipe to prevent status bar appear.
I think it's good enough for an in-house App ~

How can my app figure out (at run-time) if it is running on Android Wear?

I know how to get the build version that I'm running on:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
try {
// Update the action bar title with the TypefaceSpan instance
final ActionBar bar = getActionBar();
....
I would also like to have an (&& !wearable) in that if statement, since there is no actionBar on wearables. It would be great if it was also included in the Build class somehow.
The app isn't officially wearable yet, but this is part of some shared code, so please don't tell me to pass it in from the wearable's activity.
Thanks!
If you really want to determine if you are on a watch, I'd try PackageManager and hasSystemFeature(), to see if the device has FEATURE_WATCH. Quoting the docs:
Feature for getSystemAvailableFeatures() and hasSystemFeature(String): This is a device dedicated to showing UI on a watch. A watch here is defined to be a device worn on the body, perhaps on the wrist. The user is very close when interacting with the device.
However, as there are other scenarios where there is no action bar (e.g., TV apps), you might consider calling getActionBar() (for the native action bar) or getSupportActionBar() (for the appcompat-v7 action bar) and see if it returns null.

How to get data From Status bar and disable it?

I am creating a custom lock screen so that in my activity the Status
bar won't be there.
At the mean time i want to get the the status bar notifications such
as missed calls, new chat messages, new emails, new voice-mail, etc...
How to implement this?
please give me a hint

Categories

Resources