Android: get all the notifications by code - java

I am using some home replacement that allow me to hide the notification Bar and that's something I really like.
All the informations can be replaced by some widgets, but I would like to display the notifications too.
As I already developed some applications, I would like to know if there is a command line that allow an application to get all the notifications. I plan to add this to a widget or a toast.
Thank a lot for any clue or help.

Since Android API Level 18 (Android 4.3) there is a class NotificationListenerService.
You must set the Permission BIND_NOTIFICATION_LISTENER_SERVICE and use a intent-filter with the action NotificationListenerService.
<service android:name=".NotificationListener"
android:label="#string/service_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
Source: http://developer.android.com/reference/android/service/notification/NotificationListenerService.html#getActiveNotifications()

I will answer my question because I found something on an other forum.
Seem that you can access them declaring your application as an (sorry for the french term, I couldn't find an english translation) "gestionnaire d'accessibilité" that you may translate as "accessibility manager"
More information here: https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html
That may be dangerous and has a lot of negative point, but an other dev that is also working on a custom Home assure me that this feature work and he was able to create his own notification bar.

Related

How can I get my Android app with use Branch.io Deeplinking AND support minimize/resume the app?

I am using Branch.io deeplinking in my Android app, and for the most part, it works well under most scenarios. However, I have a scenario where I register a user (to my service); and in that flow, the user requests an SMS verification code, and thus has to leave the app (minimize) to read it, then re-enter the app (restore) to validate to code.
I had this behavior working perfectly before implementing branch.io, and the reason has to do with Branch.io requiring android:launchMode="singleTask" in the AndroidManifest.xml file (see here).
<activity
android:name="com.yourapp.SplashActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
...
When android:launchMode="singleTask" is removed, the user can leave/enter the app as much as they want and are always returned to the same activity that they were on when they minimized the app. Yet, Branch.io deeplinking is no longer respected.
HOWEVER, it seems that this minimize/restore behaivor is not (?) possible with Branch.io is implemented. Is it? How can I retain the minimize/restore functionality of my app, which implementing Branch.io deeplinking?
In addition to Amruta's comment I wanted to contribute. As singleTask is required for proper deep linking to avoid multiple instances of the same activity, our best workaround/suggestion for this issue which hasn't been mentioned yet is to create a transparent deep linking activity. This way you can set a throw away transparent activity to singleTask, init session from it it -> grab params -> route accordingly. Otherwise you're stuck adjusting your main app flow to our requirement of using singleTask. This tends to be the most popular workaround!

Creating invisible mode with code/pattern for running specific Android App

I'm building an Android App that her purpose to be secret, I dont want the icon will exist in the apps menu.
The idea is that that only the user that installed the app could use it with a private code he configured after installation.
Can I hide my app from the list and run it?
What are my options starting this app by entering kind of code/pattern for that use? and is it possibile to connect to the user lock\unlock system after screen looks and let him set a uniqe code that after entering it he could enter to the app mode.
I'll be happy getting some code or any kind of tutorials
I've seen other apps use a private dialling code/fake phone number to trigger opening a hidden app.
You can register a listener for NEW_OUTGOING_CALL and check the EXTRA_PHONE_NUMBER that is passed with it to cancel the call and open your app if the number matches your private code. Otherwise ignore and let the call go through as normal.
This obviously has permissions for that are needed that may look suspicious to potential users.
As for removing your app from the launcher as other's suggested and as described in the linked Question you need to remove the <intent-filter> from your <activity>
<category android:name="android.intent.category.LAUNCHER" />

possibilities to combine two Android App's

I would like to know what's the best possibility to combine two Android Apps together?
I am working on a Loginpage for my Project.
My friend is working on a Dataviewpage for the same Project.
I would like to know what are our options to combine these two Apps (both just in local eclipse), when we finished the seperate project's.
Our current Idea, would be to copy one part in the Eclipse and build it into the other one.
I am aware of, that this is the worst idea but I have no idea to do it an other way.
Hopefully you guys can help me out.
Thanks in advance.
One Solution can be from what i understood you problem is you want both of you should work on same App and even can do your work individual and test it.
Solution can be:
Suppose you have Login Activity & he has DataViewpage activity. Both work on same project just
Add this in the manifest file in both Activity Login and dataview
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
So This will make 2 icons and both of you can work on same code base and also can test individual pages also..
And Put your code base in github.. so can work from anywhere..
Hope this will help you

How to discover any NFC tech (not only tags) using Android?

I'm coding in java for my Android 2.3 Nexus S device. I'm having an issue trying to discover an NFC reader/writer that I recently purchased. In my manifest file, I'm using
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="#xml/nfc_tech_filter" />
All I'm trying to do is discover that some sort of NFC tech is around/available. When I bring my phone close to the NFC reader/writer, I can see the log registers some sort of event with the tags of "dalvikm" and "AudioHardware". But for some reason, the intent doesnt start my activity. My app is the only application with NFC functions - checked my defaults, etc. to make sure. In my activity, I'm simply using along with a basic layout and onCreate method:
#Override
public void onNewIntent(Intent intent) {
// TODO
Toast.makeText(this, "NFC TECH DISCOVERED!", Toast.LENGTH_LONG).show();
}
I'd expect atleast the activity to launch. Any ideas why this isnt? Maybe because I've been waving this over an NFC reader and not an actual NFC tag which I've successfully been able to find. Thought I'm not sure why the app won't atleast acknowledge there's an NFC capable device around.
The resource file contains:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.NfcA</tech>
<tech>android.nfc.tech.Ndef</tech>
<tech>android.nfc.tech.MifareUltralight</tech>
<tech>android.nfc.tech.NfcA</tech>
<tech>android.nfc.tech.IsoDep</tech>
<tech>android.nfc.tech.NdefFormatable</tech>
</tech-list>
</resources>
In "android.nfc.action.TECH_DISCOVERED" The TECH doesn't mean NFC devices it's referring to the tech on an NFC tag, ie. MifareClassic, UltraLight etc. So it won't recognise your reader/writer because it isn't a tag.
I think you're going to have a lot of trouble trying to get a desktop NFC reader/writer to communicate with the Nexus as the Nexus can't act as a tag without installing a custom ROM on it, therefore it's not able to be read or written to, and most desktop readers can't act as tags either so there's no reading or writing to them. Perhaps you could do some p2p communication but I still think this will require a lot of work.
Which NFC reader/writer do you have?
There is also mistake in your nfc_tech_filter file. At least one of your tech-lists must be subset of techs supported by tag, which you wish to communicate with. You should use more tech-lists with fewer techs. AND and OR principle is implemented this way.
However in your case with card reader, Peanut's answer is the main problem.

Making a simple honeycomb launcher

Working with a restaurant in an android tablet based menu app. If possible I would like to restrict access to just the menu app and browser. How would a I go about turning a normal dashboard app into a launcher replacement???
Add this to your <activity>:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
When the user presses HOME again, they will get a chooser -- check the "make this the default" checkbox, then tap the entry for your app, and you're now the home screen.
Bear in mind, though, that:
If you let users get to a browser, they will be able to download and run apps distributed publicly, plus click links that might lead to other apps on the device (e.g., YouTube, a PDF reader)
If the user knows how to boot your device in safe mode, the firmware home screen will return; the only solution to this is to have your home screen be installed on the firmware of the device
There is a Home sample project in your SDK that demonstrates more of this.
You can write a simple app that allows the user to start 2 different apps (the menu and the browser) using intents while never ending your main app. In that app/launcher app you can override the home/back button in such a way that it will not allow the user to quit that app/launcher. This means that once the app is started there is no way to stop it, except by turning the tablet off.

Categories