0

我有一个小部件,它可以发送和接收特定的短信,但是当我重新启动手机时,小部件不起作用。我该怎么做 ?我在 androidManifest.xml 中有那个

 <receiver
        android:name=".Inicio"
        android:enabled="true"
        android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
        <intent-filter>
            <action android:name="com.alexander.android.saldo.BOOT_COMPLETED"/>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </receiver>

我试着称之为

public static void llamarWidget(Context context) {
    int widgetId = 0;
    SMSSend.ejecutarTarea();
    Intent intentOrigen = ((Activity) context).getIntent();
    Bundle params = intentOrigen.getExtras();
    widgetId = params.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
            AppWidgetManager.INVALID_APPWIDGET_ID);
    AppWidgetManager appWidgetManager = AppWidgetManager
            .getInstance(context);
    MiWidget.actualizarWidget(context, appWidgetManager,
            widgetId);

    Intent resultado = new Intent();
    resultado.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
    ((Activity) context).setResult(RESULT_OK, resultado);
}
public class Inicio extends BroadcastReceiver{

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        WidgetConfig.llamarWidget(context);
    }


}
4

0 回答 0