How to make android launch an application on received specific sms [duplicate] - android

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
BroadcastReceiver + SMS_RECEIVED
Lets say i have an application i want to launch every time my phone receives a specific text message, a keyword for example. Can i do this if my application is not running? What' s a good way to do it?
I have never tried this before and i want to run an application on one phone which will send a specific text message to another phone (done so far), then the 2nd phone would start an application when the message is received (after checking the message to see if its the keyword).

You need to write a BroadcastReceiver with the following intent filter
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>

You'll need to create an AlarmManager for this with a BroadcastReceiver in order to receive data when your application is not running, I believe.
Although this may not be possible, as it could be considered a security risk to read the contents of a user's text messages... this would require some nasty permissions, and your users may not want to use the software because of that. Try taking a look at some of the Amazon free app of the day reviews to see how bad this can be for your app.
Other than that, you should be able to use the classes stated above in order to implement this. Let me know if this isn't clear and I'll try to expand upon it.
EDIT:
My mistake, a more appropriate way to handle this would be through a Handler with a background Service. I haven't personally used this myself, so I can't tell you much more than the documentation. Try reading the documentation and looking at the examples :)

Related

How to get all intent filters for application (with root)

I am working on a system application and I need to know programmatically what intents an application is capable of handling. I have seen other questions related to this, but none of them seem to have an answer but also do not seem to be concerned with system privileges.
PackageManager only seems to provide methods to query activities for a given intent. I can not find a way to get intents for a given activity.
For example, if I have an activity which has intent filters defined as such:
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.USER_PRESENT"/>
</intent-filter>
And I know the activities class name and package name, I would like to find out from the package manager (or any other source) what intents it can handle (in this case, BOOT_COMPLETED and USER_PRESENT).
Good question. I don't think it's possible to find out the intents that an app can handle. Some standard activity actions and broadcast actions are listed at http://developer.android.com/reference/android/content/Intent.html. If you are writing your own app that's having it's own intent filters, then i don't think other apps will know what intents your app can handle because there is no way to publish them or announce them to the world, i believe.
But what is possible is that you can make a call for a particular intent and if that returns null, then you know for sure that there are no apps on the device that can handle that particular intent.
HTH.
So after just asking this question, I found this wonderful answer here:
Android — How to I get a list of all available intent filters?
Which leads to this 5 year old issue
So it doesn't seem like there is any way to do what I want to do at the moment. If it becomes available, I would love to know.
you could try a decompiler, such as "DexDump" (available on GooglePlay), and retrieve the "AndroidManifest.xml" of the application you want to know about.

How to prevent SMS going to inbox in Android Kitkat

In previous versions of android we could block SMS by using following code:
<receiver android:name=".broadcastreceivers.OnSMSReceived"
android:exported="true" android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="1000">
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
and in broadcast receiver, abortBroadcast() function prevent SMS from going to inbox.
But this method is not working in kitkat as, from Kitkat SMS will only be received by default SMS app. Is there any workaround to create SMS blocker app in kitkat?
You should read this page: http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html
A change was introduced in KitKat that only allows one application at a time (the default SMS app) to have write permissions on the SMS DB and to be able to consume it.
You have 2 ways of solving your problem:
Follow Google advice on how to request the user to switch the default SMS application to your application during the time when you need to perform your changes (and once you finish doing it, allow the user to switch back to the original default SMS app).
Find a temporary hacky way to do what you need to do. As a hint, there is a hidden API: AppOpsManager#setMode that you could potentially exploit in order to give your application write permissions (OP_WRITE_SMS), head over to this XDA page to learn more about it: http://forum.xda-developers.com/showthread.php?t=2551072
Needless to say, any hacky solution is just temporary as a private/hidden API could change at any moment. It is strongly encouraged to implement what Google advised us to implement which again is described here.
you can check that your application is a default SMS application or not. for this purpose see this link. you can get the package name of default SMS app and check with your name, if equal with each other then you can block SMS with Delete from inbox. this should be worked for you.
I know this is an old question, but here's a possible solution to KitKat SMS blocking:
http://superdupersms.com/
Since it isn't a technical solution but rather a product based solution, it's possible this should be a comment and not an "answer" - and I am involved in the development.
But I haven't found any other solution that allows other apps to interact with the SMS database like they did prior to KitKat - which directly addresses the question. This solution allows a non-default SMS app to block SMS.

How to manage delivery of NFC tags to multiple apps

I want to create an app that stores a timestamp into the database when I scan my work-batch which contains an NFC tag. This will be done via an IntentService without starting an activity. After a second scan another timestamp will be stored into the database via the IntentService. No activity has to be started. A notification will be enough. The activity can be started manually by the user to see the info.
I have read that there are a lot of different tag technologies. But I like to make my app a bit more universal. So I don't know which kind of NFC tags my clients are going to use. I could listen for all the different tags and let the user pair a tag with a certain task.
This is fine unless there is one NFC app on the phone. But I have another app which uses NFC. And when I scan a tag Android shows me a selection dialog which app may handle the tag. But I don't want this every time I scan a tag. I want to use both apps so I dont select a default for the tags.
So the question is, How can I scan a tag and route it to the right app. So tag A will be handled by app A and tag B by app B without getting the selection box every time.
I was thinking what the best option should be or maybe somebody has a great idea how to solve this.
I have taught of a couple of different solutions:
Use only writable NDEF tags and add a Android Application Record (AAR) to it. So it will launch the right application after scanning. (If there is no NFC app active in the foreground) this will mean that the user is restricted to a tag technology and needs to write it before using.
Let the application listen for all NFC tags and if a tag is not paired to a task forward it to the system again so that other apps can handle it. (Don't know if this is possible)
Write a app which listens for all NFC tags and let the user decide which tag will be send to which application. So when a new tag is received by the application it asks the user which app may handle the tag and stores the default for this specific tag [by ID or something] into a database. So the next time it will route the intent to the default application for this tag. (Or is there already something like this?)
Hopefully this question is a bit clear. Else I'll try to clarify it a bit more if you like ;-)
I really like to hear what you think about this. Or maybe you have some good suggestions? Please let me know.
Thanks in advance.
I've successfully use an application specific URL scheme for this. Let's assume your URL scheme is "kuiperstimestamp".
The tag then should contain a URL like:
kuiperstimestamp://ts/20130506T034536.293
You then create an intent filter for your service that includes a data element:
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="kuiperstimestamp" />
</intent-filter>
Since the intent filter is rather specific, you don't get the app selection dialog (unless another app or service has the same specific intent filter which is unlikely).
This approach is less Android specific than using an AAR.

Is it possible to get latest missed call or received sms notification from a class which we created on android?

I am able to see getting new sms or calllog from apks which I built but my question is that;
for example I create a .class which in
<com.example.xx
Can I use it on my any other apk's layout xml file using <com.example.xx ... /> using with layout width and height.
Is that possible? If so can you create this class file ?
( I know manifest needs receiver and permissions for latest missed calls & messages)
I hope I can explain clearly what I mean
I'm also not sure what you're asking, but...
Yes, you can access the latest sms or the call log from any Activity you want, from any apk you want, and/or from pretty much from anywhere you want on the phone.
You'd use a Content Provider to access that information. If you wanted to, you could even use a Broadcast Receiver to trigger your application whenever you received a message or phone call.
And yes, you could even do this in a library if you wanted (so that others could use it from their own layouts). If that's what you're asking.
And yes, you could even do this from one apk to another apk through intents if you wanted (not that I would see any advantage to doing that). May be, that last one is not what you were asking.
Have I answered your question?

Android, find the sender of an Intent for a monitoring application

I'm developing a monitoring application for Android listening for broadcast intents: whenever some suspicious intent pattern occurs a dialog alerting the users pops up. Indeed the intents must have been triggered by the same application, to avoid useless warnings.
In general this seems not to be possible, for instance I found something here: How to find Intent source in Android?
I'm asking if there is a workaround to this, for instance looking into the context or whatsoever. I really need the application name, not the just the application name to do something else.
Cheers,
Gil
I'm developing a monitoring application for Android listening for broadcast intents
I sincerely hope that you fail in your quest, as this should not be possible, for obvious privacy and security reasons.
I'm asking if there is a workaround to this, for instance looking into the context or whatsoever.
AFAIK, no, short of creating your own custom firmware.

Categories

Resources