I am trying to make an existing android app wearable.
Is it necessary, or not, to specify the full package path for setting a media button event receiver?
I haven't seen any explanation in the official documentation. It is as follows in the documentation:
<receiver android:name=".RemoteControlReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
While I have this in my current code:
<receiver android:name="com.pckg.my.app.subpack.RemoteControlReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
Try to add (.) in the beginning of your android name
<receiver android:name=".com.pckg.my.app.subpack.RemoteControlReceiver">
Related
I have broadcast receiver for date change event, it works fine for kitkat and lolipop version but not working in marshmallow.
code is as follow
<receiver
android:name=".DateChangedReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.TIME_SET" />
</intent-filter>
</receiver>
what should I do for that? is their any special permission required? Please help
You are right . This intent action may be restricted to system apps only . Adding the android:permission="android.permission.BIND_DEVICE_ADMIN" to the receiver is working for me .
PFB update receiver definition
<receiver
android:name=".DateChangedReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BIND_DEVICE_ADMIN"
>
<intent-filter>
<action android:name="android.intent.action.TIME_SET" />
</intent-filter>
</receiver>
My widget won't install. I'm trying to install a home screen widget using android. I've put the widgetprovider in the manifest along with a configuration class. It just doesn't show up in the list of widgets and I hence can't install it! Console gives no errors.
The update widget receiver is there in the manifest. But the widget isn't even created so what's the point? The widget won't get created!
I've created the layout, created the widget information file and filled in the fields, registered it in the manifest, created the classes, it still won't work.
<receiver
android:name=".WidgetProvider"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.appwidget.action.WIDGET_PROVIDE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/widget_info"/>
</receiver>
<activity
android:name=".WidgetConfig"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.appwidget.action.WIDGET_CONFIG" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
There is an error in your manifest. The intent filter should contain
action android:name="android.appwidget.action.APPWIDGET_UPDATE"
not:
action android:name="android.appwidget.action.WIDGET_PROVIDE"
If you have more than one widget provider, each one needs its own receiver containing this action. Here is an example for one widget provider:
<receiver android:name=".WidgetProvider"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="#layout/widget_provider_2x1"/>
</receiver>
When I change the namespace of my widget provider, the widget goes blank and doesn't work until I delete it and add it again.
How would one change the namespace and the receiver name for a widget without breaking already placed widgets.
Before rename:
<receiver android:name="com.creativitality.labs.timezoneswidget.WidgetProvider" android:label="#string/widget" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget_info_large" />
</receiver>
After moving and renaming provider:
<receiver android:name="com.creativitality.labs.timezoneswidget.widget.WidgetLarge" android:label="#string/widget_4x1" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget_info_large" />
</receiver>
For activities, you can create an <activity-alias> element in your manifest that points to the new name of the <activity>.
There is no solution for receivers. <receiver-alias> does not exist. Your receiver must keep its original name forever or it will break.
I want to start a service in an APK.
I tried to use as following:
<application android:icon="#drawable/icon" android:label="#string/app_name">
<service android:name =".TestServcie">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</service>
</application>
Any ideas?
Thanks
You can write a BroadcastReceiver and run the Service after receiving the Intent. For example after device boot-up or other Intent that you need.
<receiver android:name=".StartupReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>
No you can't.
Create a simple Activity which starts the service and simply provides some feedback to the user (to tell them the service has started for example) and set that Activity with the MAIN/LAUNCHER intent.
I am trying to solve a start on boot related problem and I noticed many examples of the AndroidManifest.xml which has android.intent.action.BOOT_COMPLETED and some that also have the category of android.intent.category.HOME in there. Does anyone know what the difference (if any) between the two are?
ie.
<receiver android:name=".MartiniBootBroadCastReciever"
android:enabled="true" android:exported="false"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
versus
<receiver android:name=".MartiniBootBroadCastReciever"
android:enabled="true" android:exported="false"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
AFAIK, your first one is wrong. The BOOT_COMPLETED broadcast should not have that category, AFAIK.