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?
Related
I have an App that uses a Service that I've added by a Bindable Jar.
Current state:
this Jar has an own Manifest (see below), when I don't touch anything on this Manifest everything works as it should.
Problem:
This Jar lets on Deployment to Device always its launer AppIcon on Device.
So my App leaves finaly two launcher icons, the one desired and the other from the Jar.
My Approach was to delete follow Part from Manifest:
android:theme="#style/AppTheme">
<activity
android:name=".ScanDemoActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Doing this the App Crashed on BootUp with Error: BootReceiver not found ...
Deleting the next few Lines:
<receiver android:name="com.company.scandemo.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>
caused started correctly on bootUp, but the Service didn't come up on BOOT_COMPLETED, when I start the App via Launcher icon everything worked.
Wished Behaviour:
I want the Main App to leave only one launch Icon and startup correctly on Boot
Here is the Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.scandemo"
android:versionCode="1"
android:versionName="2.2" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name=".ScanDemoActivity"
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="com.company.scandemo.FloatingService" />
<receiver android:name="com.company.scandemo.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>
</application>
</manifest>
My launcher activity not starting can any body tell me whats the problem.
I also have a service in it.
Any help is appreciated Please help i am stuck and don't know what to do.
Here is the code of Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pelicans.abc.abc">
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-feature android:name="android.hardware.camera" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Permiss"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:screenOrientation="portrait">
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable">
</meta-data>
</activity>
<service
android:name=".Service.FeatureService"
android:enabled="true">
</service>
<receiver android:name=".Receiver.RestartService"
android:enabled="true"
android:exported="true"
android:label="RestartServiceWhenStopped">
<intent-filter>
<action android:name="Restart_Service"></action>
</intent-filter>
</receiver>
</application>
</manifest>
Launcher activity is not called in any version of android.
Try this :
I think remove this:
<intent-filter>
<action android:name="Restart_Service"></action>
</intent-filter>
//need to modified
<meta-data
android:name="android.app.searchable" //it must contain package name and .searchable
android:resource="#xml/searchable">
</meta-data>
OR
<intent-filter>
<action android:name=".Restart_Service"></action> //add dot
</intent-filter>
really no log?..try more times,try to Log at application onCreate() and activity onCreate()
delete sth,like your MainActivity or RestartService,and try again
If launcher icon is working and launching from studio is not working, then disable Instant Run and try.
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" />
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.
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