I want to receive the ACTION_MEDIA_SCANNER_FINISHED, but it doesn't work.
Below is my manifest about receiver.
<receiver android:name=".MyReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_SCANNER_FINISHED" />
<data android:scheme="file" />
</intent-filter>
</receiver>
I've browsed through many related articles, but there is no correct answer and most of them are quite old.
I wonder whether it is related with API level or device or system app?
Related
I have registered a broadcast Receiver with which should wake the application up on every reboot,
receiver android:name=".Receiver.NewLocationReceiver"
<intent-filter>
<category android:name="android.intent.category.HOME" />
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="YouWillNeverKillMe" >
</action>
</intent-filter>
</receiver>
Still the BOOT_COMPLETE filter if failing to do its job, Unable to tackle a particular scenario. Is there anything I need to add so that I can completely avoid this situation.
Popular pitfalls:
BOOT_COMPLETED is delivered to all relevant (registered) broadcast receivers only upon unlocking the device.
It is delivered in some order, so you may be last in that list and will take some time.
Make sure you have the presmission <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
I have an app that has the ability to be launched whenever I receive an SMS with a certain format, it works correctly when using the Android stock Messages app but, when testing on a Samsung device using their Messages app and clicking a link, it won't launch my app but instead try and open the link inside the Messages app, current implementation on AndroidManifest.xml
<activity android:name="com.example.SMSInterceptor"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="example.com" />
</intent-filter>
</activity>
Anyone know any solution to this? Any help is appreciated.
add to your intent filter auto verify like below:
<intent-filter android:autoVerify="true">
Here's my current setting in my android manifest:
<receiver
android:name=".receivers.BaseReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package" />
</intent-filter>
</receiver>
<receiver
android:name=".receivers.BootReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
I've separeted those receivers because the packages only work with <data android:scheme="package" /> and the boot receiver stops working if I add thise schema to my filter.
Now my question:
Does that consume more battery? Or does it matter if I summarize the package receivers in one? Or can I just create as many receivers as I want as android will not run anything and just checks the manifests of all installed apps on demand?
Receivers are handled by the system. That is the system that send a message when the action happened so you can as many receivers as you want it won't affect the battery you just have to handle them properly.
And for the question one or many, it depend of the use you make of them. It will be easier to handle one in certain cases, for other cases it will be easier to have many to handle them separetly.
I am working on an email app where I have specified intent-filters on an activity so that other apps can share things from it. Every other apps show my email app intent while sharing but WhatsApp does not show it when I share Email Conversation.
My Actvity is defined in AndroidManifest as shown below:
<activity
android:name="com.test.myapp.ComposeActivity"
android:configChanges="orientation|keyboard|screenSize|screenLayout" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="mailto" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="mailto" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
How can I make my app visible while sharing through WhatsApp?
Figured out it, props to this answer
Turns out that WhatsApp is whitelisting the packages that show up on the chooser. Some whitelisted email clients are outlook, k9 (didn't actually work for me so that may be outdated) and gmail/android email.
One workaround is to have the same application id as one of these whitelisted packages (I've verified this still works) but obviously you won't be able to publish to the app store. If you were desperate you could potentially create another app and bundle the apk into your assets/raw and have them install it from there. This app could share the domain of one of the whitelisted packages and securely transfer this intent to your main app*.
I do not advocate for this approach, just saying it's an option.
I am new to android. I am using a Broadcast receiver which listens when a app is installed or removed.. When a app is installed or removed my Broadcast Receivers's onReceive(context,intent) will be called.. Now i need to get the info about the application installed or removed (Mainly the package name)..
Plz help
You can try this receiver and permission. (But this seem only work in /system/app)^^"
<receiver
android:name="com.your.receiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package"/>
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" />
All the information you want is in the Intent extras.
Look at How to find the package name which has been uninstalled when using Intent.ACTION_PACKAGE_REMOVED