I want to start BroadcastReceiever on installation of my application. I found some Thread over stackoverflow that this could be done by using Boot Complete BroadCastReceiever.
But After writing code we could not get success because my receiver did not call at all.
Manifest File:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.broadcastdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.broadcastdemo.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
>
</activity>
<receiver android:name="com.example.broadcastdemo.BootReceiver"
android:enabled="true"
android:exported="false"
>`
`
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>
Did you register the receiver in manifest.xml
<receiver
android:name="YOUR_ACTION_STRING.BootCompletedReceiver"
android:enabled="true"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
Related
in writing a widget and after i tried to add a setting activity for my widget , i got the error "No Launcher activity found!"
this is my AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.persianweather"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<receiver android:name="com.example.persianweather.Main" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<!-- This specifies the widget provider info -->
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget" />
</receiver>
<activity
android:name="com.example.persianweather.SettingActivity"
android:label="#string/title_activity_setting" >
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
</application>
No Launcher activity found! means that you not mentioned any activity on launching the application. Try to add these lines in manifest. To specify these MAIN and LAUNCHER in the the intent filter for the activity you want to start on launch like:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Note: Multiple action tags in a single intent-filter tag will also cause the same error.
Make your SettingActivity as launcher activity, Only then you will be able to proceed further,
<activity
android:name="com.example.persianweather.SettingActivity"
android:label="#string/title_activity_setting" >
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Can someone spot the error in my AndroidManifest.xml? To me I have all the tags correct.
I have checked the other questions but have not spotted anything. The X in eclipse is on the application start tag.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="***"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.msc.mymedisense.Welcome"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.msc.mymedisense.MainActivity"
android:label="#string/title_activity_main"
android:parentActivityName="com.msc.mymedisense.Welcome" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.msc.mymedisense.Welcome" />
</activity>
<activity
android:name=".AppSettingsActivity"
android:label="#string/title_activity_AppSettings">
</activity>
<activity
android:name=".NotificationActivity"
android:label="#string/title_activity_notification">
</activity>
<receiver android:name=".TimeAlarm" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
I created an widget and it is not showing on the widget list, but when I go to Settings->Application Manager, the widget IS on the app list. I was debugging it and it was working like a charm before, but it disappeared suddenly. I assume it has to do with my manifest. If you need the rest of the code, I can put it on my dropbox.
I am currently running 4.1.1 and my log states there isn't any issues... help :/
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ps.transparenttogglewidget"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<!-- AIRPLANE MODE CODE -->
<receiver android:name="AirplaneModeWidget" >
<intent-filter>
<action android:name="android.appwidget.action.AIRPLANE_WIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/airplane_mode_provider" />
</receiver>
<receiver
android:name="AirplaneModeIntentReceiver"
android:label="AirplaneModeBroadcastReceiver" >
<intent-filter>
<action android:name="com.ps.transparenttogglewidget.intent.action.AIRPLANEMODE_CHANGE_STATUS" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/airplane_mode_provider" />
</receiver>
<receiver android:name="AirplaneModeReceiver">
<intent-filter>
<action android:name="android.intent.action.AIRPLANE_MODE">
</action>
</intent-filter>
</receiver>
<!-- WIFI MODE CODE -->
<receiver android:name="WifiModeWidget" >
<intent-filter>
<action android:name="android.appwidget.action.WIFI_WIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/wifi_provider" />
</receiver>
<receiver
android:name="WifiModeIntentReceiver"
android:label="WifiModeBroadcastReceiver" >
<intent-filter>
<action android:name="com.ps.transparenttogglewidget.intent.action.WIFI_MODE_CHANGE_STATUS" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/wifi_provider" />
</receiver>
<receiver android:name="WifiModeReceiver">
<intent-filter>
<action android:name="android.intent.action.WIFI_MODE">
</action>
</intent-filter>
</receiver>
</application>
</manifest>
I am building a simple sms app , i want to open my app automaticaly when ever a new sms is received? is it even possible?
i am using broadcast receiver for this
what changes should i made in manifest?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.message"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MessageActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<receiver android:name=".SmsReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</activity>
<activity android:name=".Reply" >
</activity>
</application>
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
</manifest>
you should move the receiver outside from the activity like this:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MessageActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Reply" >
</activity>
<receiver android:name=".SmsReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
Under Android 3.0 and later, your broadcast is not guaranteed to be received unless the user has opened your application. The application does not have to remain opened, just to have been started once. This is caused by a flag (FLAG_EXCLUDE_STOPPED_PACKAGES) which is now part of most system broadcasts, which says the broadcast should not start a stopped application.
This was already answered in How to make android launch an application on received specific sms to keep it short: it is possible with BroadcastReceiver.
my widget is full and ready to work, after i install it i can't find in the emulator widgets list .. although it's there when i search for it in the installed applications .. i think it's a problem in the manifest, here is the manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="help.i.bored.bad" android:versionCode="1" android:versionName="1.2">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<!-- Broadcast Receiver that will process AppWidget updates -->
<receiver android:name=".HitsWidget" android:label="#string/app_name">
<intent-filter>
<action android:name="help.i.bored.bad.HitsWidge.receiver1" />
<action android:name="help.i.bored.bad.HitsWidge.receiver2" />
<action android:name="help.i.bored.bad.HitsWidge.receiver3" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/hitswidge_provider" />
</receiver>
<Service android:name=".MediaService">
<intent-filter>
<action android:name="help.i.bored.bad.HitsWidge.receiver2" />
<action android:name="help.i.bored.bad.HitsWidge.receiver1" />
</intent-filter>
</Service>
<Activity android:name=".Stations" android:label="#string/app_name">
<intent-filter>
<action android:name="help.i.bored.bad.HitsWidge.receiver3" />
</intent-filter>
</Activity>
</application>
Your Broadcast receiver doesn't listen for the android.appwidget.action.APPWIDGET_UPDATE action. This is all covered in:
AppWidgets