I’ve got an application with a widget in one .apk file.
Widget reacts on incoming sms and other app-specific events. And also it launches the main activity when user clicks on it.
The problem is that when user starts an activity (clicking on a widget or from applications menu – doesn’t matter) and then kills an application using task manager – my widget stops receiving any intents (like TIME_TICK).
I know that solution for my problem exists (I saw apps in android market which widgets are able to launch an activity after it was killed by user)
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:a="http://schemas.android.com/apk/res/android"
package="ru.studiomobile">
<application a:icon="@drawable/icon" a:label="@string/app_name">
<!-- Widget -->
<receiver a:name=".widget.WidgetProvider" a:label="@string/app_name">
<intent-filter>
<action a:name="android.MyWidget.ACTION_ON_WIDGET_CLICK"/>
<action a:name="android.MyWidget.ACTION_CHANGE_DAY_NIGHT"/>
</intent-filter>
<meta-data a:name="android.appwidget.provider"
a:resource="@xml/widget_provider"/>
</receiver>
<service a:name=".widget.UpdateService" a:label="UpdateService"
a:exported="false">
<intent-filter>
<action a:name="android.MyWidget.ACTION_ON_WIDGET_CLICK"/>
<action a:name="android.MyWidget.ACTION_CHANGE_DAY_NIGHT"/>
</intent-filter>
</service>
</application>
</manifest>
Probably you need to have a service http://developer.android.com/reference/android/app/Service.html
instead of just activity. Service monitors incoming sms.