Merge pull request #192 from arkon/fix/boot-widgets
Start service after boot to show data in widgets
This commit is contained in:
commit
7f3aedd93c
2 changed files with 36 additions and 1 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
|
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
|
||||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="com.android.vending.BILLING" />
|
<uses-permission android:name="com.android.vending.BILLING" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
|
@ -145,7 +146,14 @@
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.bumptech.glide.integration.okhttp3.OkHttpGlideModule"
|
android:name="com.bumptech.glide.integration.okhttp3.OkHttpGlideModule"
|
||||||
android:value="GlideModule" />
|
android:value="GlideModule" />
|
||||||
|
|
||||||
|
<!-- Widgets -->
|
||||||
|
<receiver android:name=".appwidgets.BootReceiver" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".appwidgets.AppWidgetBig"
|
android:name=".appwidgets.AppWidgetBig"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.kabouzeid.gramophone.appwidgets;
|
||||||
|
|
||||||
|
import android.appwidget.AppWidgetManager;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import com.kabouzeid.gramophone.service.MusicService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Eugene Cheung (arkon)
|
||||||
|
*/
|
||||||
|
public class BootReceiver extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
final AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);
|
||||||
|
|
||||||
|
// Start music service if there are any existing widgets
|
||||||
|
if (widgetManager.getAppWidgetIds(new ComponentName(context, AppWidgetBig.class)).length > 0 ||
|
||||||
|
widgetManager.getAppWidgetIds(new ComponentName(context, AppWidgetClassic.class)).length > 0 ||
|
||||||
|
widgetManager.getAppWidgetIds(new ComponentName(context, AppWidgetSmall.class)).length > 0) {
|
||||||
|
final Intent serviceIntent = new Intent(context, MusicService.class);
|
||||||
|
context.startService(serviceIntent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue