Handle network configuration sms - java

I want to handle received sms that contains network configurations(OMA OTA). I have already developed android application that catches typical sms from inbox. Network configuration is not a typical sms. How can I get it? What is a Broadcast Action for that?
I was trying this:
<receiver android:name="ru.tenet.pdureceiver.SMSReceiver" >
<intent-filter android:priority="1" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
As I understood, android.provider.Telephony.SMS_RECEIVED is not enough.

Well, I've found a solution. The action is:
android.provider.Telephony.WAP_PUSH_RECEIVED
And also there must be a mimeType defined for wap message.
For example:
<intent-filter android:priority="1" >
<action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />
<data android:mimeType="application/vnd.wap.connectivity-wbxml" />
</intent-filter>

Related

App not receiving boot completed intent in some devices

i created an app that always start a service once the device has completed booting.
This is the Manifest code..
<receiver>
android:name="StartMyServiceAtBootReceiver"
android:directBootAware ="true"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
<action android:name="android.intent.action.REBOOT"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
The service always start in some devices once boot is completed but in my own device which is running android 7.0, the boot completed service doesn't start unless i convert the app to system app using root access. Can someone tell me how to make the app to start the service on boot completed without converting it to a system app?
First of All
receiver android:name="StartMyServiceAtBootReceiver"
Your path to Receiver should written over here for example:
<receiver android:name=".receiver.BootReceiver">
first dot suggest your path till root of the package.
Create a BroadcastReceiver and register it to receive ACTION_BOOT_COMPLETED. You also need RECEIVE_BOOT_COMPLETED permission.
Read: Listening For and Broadcasting Global Messages , and Setting Alarms
Try into manifest
<receiver
android:name=".AutoStart"
android:enabled="true"
android:exported="true" >
<intent-filter android:priority="500" >
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
Make sure also to include the completed boot permission.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
Also read this answer carefully

Add flags to incoming broadcasts

I need to listen for Install, Updates and Remove broadcasts via a BroadcastReceivers, here is the definition:
<receiver android:name=".InstallReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package"/>
</intent-filter>
</receiver>
Now, Is it possible to add Intent.FLAG_RECEIVER_FOREGROUND flags to these incoming intents? because in android KitKat receivers affect to foreground services due to bug which reported here.
Any ideas on how to add this flag to incoming broadcasts?
While you are welcome to call addFlags() on the Intent, it will not have any effect. Only the flags added by the broadcaster matter, and you are not the broadcaster.

Track Applications on Android

is it possible to keep track of install/uninstall actions of Applications on the Android system? I was not able to find a proper Intent Action or Broadcast event so far.
What I'm searching for an observer for applications like there are observers for Calendar or CallLog changes. Does there exists an CONTENT_URI or Broadcast event?
Regards
You can create a broadcast receiver for package install and unistall.
<receiver android:name=".YourReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package"/>
</intent-filter>
</receiver>
For More info go to link

How to detect/read NFC tag in service

How can I read NFC tag in background via service? I already can read it in activity(I've found some source codes but I don't really understand how it works) but I can't find anything about reading it in Service or Runnable.
Thanks for help
Finally i figured out how to solve it. I have to use these intent filters in AndroidManifest.xml to properly run my activity.
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Android unregisterReceiver with onPause

I have something like this in my manifest file - I need one receiver for the situation that a power source was connected and the other receiver for unplugged source.
<receiver android:name=".PowerConnectionOnReceiver" >
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
</intent-filter>
</receiver>
<receiver android:name=".PowerConnectionOffReceiver" >
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</receiver>
But I want to unregisterReceiver, when onPause is called in my MainActivity. How to do it?
If your broadcast receiver is specified in the manifest, it cannot be unregistered programmatically. You will need to take it out of the manifest and register it from within your code.
You cannot unregister these receivers because they are defined in manifest, not in code. Receivers which are defined programmatically are the one which may get unregistered.

Categories

Resources