I wrote a simple Service which should be invoked on startup.
I don't haver (or need) any activities to be invoked on startup, but only that service.
Here is my manifest - what am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.servicelistening"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<receiver android:name=".Index" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"/>
<action android:name="android.view.InputMethod" />
</intent-filter>
</receiver>
<receiver android:name=".StartupReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>
<service android:name=".OnOffService" android:enabled="true"></service>
</application>
</manifest>
The “No Launcher Activity found!” message is not something that should throw you off, since you already know that no launcher activity is found. You can simply ignore this error. To launch your service, broadcast the intent that is needed, and your code will run. If you want, you can add a simple test activity that will test this - but really,
no further action is required.
Related
I want to start my activity ON_BOOT_COMPLETED. Now i am facing one strange problem.
If i specify boot permission outside of Receiver tag, outside of application tag. Activity gets started. following
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.broadcaststaticdemo.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.broadcaststaticdemo.StartAppOnBoot" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
If i specify permission inside receiver tag my activity does not get started.
following
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.broadcaststaticdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.broadcaststaticdemo.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.broadcaststaticdemo.StartAppOnBoot"
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>
While i have used the second approach (permission inside receiver tag) in my other application it is working completely fine. So i am confused what is difference between specifying permission at application level and receiver level. I have seen android documentation where they have mentioned
The name of a permission that broadcasters must have to send a message to the broadcast receiver. If this attribute is not set, the permission set by the element's permission attribute applies to the broadcast receiver. If neither attribute is set, the receiver is not protected by a permission. which mean we can specify any where. Any help will be appriciated
When you use <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> it gives your application the ability to talk to interfaces that require the RECEIVE_BOOT_COMPLETE permission.
But when you assign the attribute android:permission in <receiver> you are stating that anything that interfaces with your broadcast receiver requires the permission RECEIVE_BOOT_COMPLETE. More info about it is here http://developer.android.com/guide/topics/manifest/receiver-element.html#prmsn.
I already see the questions about "No Launcher activity found!".
I developped a widget which worked well and suddenly I have this error.
I have a configure activity declared with an intent filter APPWIDGET_CONFIGURE.
Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tina.prime"
android:versionCode="5"
android:versionName="1.3.2">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<receiver android:name="tina.prime.TheWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/config" />
</receiver>
<service android:name="tina.prime.UpdateWidgetService"></service>
<activity android:name=".ConfigureActivity">
<intent-filter>
<action android:name="android.app.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
</application>
</manifest>
The error tells you everything: No Launcher activity found
This means that you haven't declared any activity in your manifest as a launcher, in order to fix this, pick the activity you want to use for starting the app, and add the following attribute to it:
<category android:name="android.intent.category.LAUNCHER" />
I am fairly new to Android programming and I'm doing my best to understand the tutorial. I have downloaded the sample code from this link.
Now I want to integrate the code from this thread. It says here to "declare the SMS receiver in your AndroidManifest.xml"
The code is:
<receiver android:name="mypackage.SMSReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.RECEIVE_SMS" />
Here's the existing code from the sample file I downloaded under AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.smsTest"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".SMSTest"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.SEND_SMS">
</uses-permission>
<uses-permission android:name="android.permission.RECEIVE_SMS">
</uses-permission>
</manifest>
Now my question is where to add the code (the first code above) into AndroidManifest.xml.
I tried to change this line:
<action android:name="android.intent.action.MAIN" />
with this:
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
without luck.
Any help is appreciated.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.smsTest"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".SMSTest"
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="mypackage.SMSReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.SEND_SMS">
</uses-permission>
<uses-permission android:name="android.permission.RECEIVE_SMS">
</uses-permission>
</manifest>
You need to add the receiver as a 2nd item inside the application. You don't replace the intent filter on the activity. It should go between the and tags.
The manifest is really describing whats in your apk. Your application will have 1 activity, SMSTest, that is launched from the launcher. It also has 1 receiver which receives the intent SMS_RECEIVED. So both parts need to be in there. Make sense?
I have made my own sms app with a reciver.
Now the emulator doesn'T start the app when run it via eclipse.
On my phone i can't press open after installing and the App Drawer doens't show my app.
the behaviour is like a widget
MY Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.korn.websms"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".WebSMSActivity"
android:label="#string/app_name" >
</activity>
<receiver android:name=".SmsReceiver" android:exported="true" >
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
</manifest>
you haven't declared a Main and Launcher activity that would be launched when the app is installed.
this should be declared within your main activity
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
You are missing a couple of lines from your manifest if you are looking to launch your app from an icon on the screen...
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
The first one (MAIN) means that this activity is the entry point of the application, when you launch the application, this activity is created.
The second one (LAUNCHER) means that it should show up in the Launcher as a top level app.
It's probably a very simple question but since I'm new to android development...
I am trying to start a service from an activity that is not in the same package (remote service) with the following code:
Intent i = new Intent("com.vasilis.service.GPSService");
i.putExtra("com.vasilis.service.GPSEnable", true);
this.startService(i);
but nothing happens with this code!
the manifest of the service project/package...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vasilis.service" android:versionCode="1" android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".serv_activity" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".GPSService" android:exported="true" android:enabled="true"></service>
<activity android:name=".incomingCallActivity" android:label="#string/app_name"
android:theme="#android:style/Theme.Dialog"></activity>
<receiver android:name="OnBootCompleteReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
</manifest>
I am missing something! Any help ?
A similar question was asked here: How do I start a service which is defined in a different package?
Pretty much you just need to add this to the manifest.xml
<service android:name=".GPSService" android:exported="true" android:enabled="true">
<intent-filter>
<action android:name="com.vasilis.service.GPSEnable" />
</intent-filter>
</service>
Or whatever the names of the classes are ;) If this doesn't seem to work, the documentation located at Service has a lot of good advice.