当前位置: 首页>>代码示例>>Java>>正文


Java AppWidgetManager.INVALID_APPWIDGET_ID属性代码示例

本文整理汇总了Java中android.appwidget.AppWidgetManager.INVALID_APPWIDGET_ID属性的典型用法代码示例。如果您正苦于以下问题:Java AppWidgetManager.INVALID_APPWIDGET_ID属性的具体用法?Java AppWidgetManager.INVALID_APPWIDGET_ID怎么用?Java AppWidgetManager.INVALID_APPWIDGET_ID使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.appwidget.AppWidgetManager的用法示例。


在下文中一共展示了AppWidgetManager.INVALID_APPWIDGET_ID属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Find the widget ID from the intent.
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
        mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
                AppWidgetManager.INVALID_APPWIDGET_ID);
    }

    // If they gave us an intent without the widget ID, just bail.
    if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
        finish();
        return;
    }

    setTitle(R.string.unread_widget_select_account);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:20,代码来源:UnreadWidgetConfiguration.java

示例2: updateWidget

static boolean updateWidget(Context context, int widgetId, String path) {
    if (TextUtils.isEmpty(path) || widgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
        return false;
    }
    String name = PFile.getNameWithoutExtension(path);
    int requestCode = ScriptWidgets.getRequestCodeForAppWidgetId(widgetId);
    Log.d(LOG_TAG, "updateWidget: id = " + widgetId + ", requestCode = " + requestCode + ", path = " + path);
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_script_shortcut);
    views.setOnClickPendingIntent(R.id.widget, PendingIntent.getActivity(context, requestCode,
            new Intent(context, RunIntentActivity.class)
                    .putExtra(CommonUtils.EXTRA_KEY_PATH, path)
                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_UPDATE_CURRENT));
    views.setTextViewText(R.id.name, name);
    appWidgetManager.updateAppWidget(widgetId, views);
    ScriptWidgets.setPathForAppWidgetId(widgetId, path);
    return true;
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:18,代码来源:ScriptWidget.java

示例3: onListItemClick

@Override
@SuppressWarnings("unchecked")
protected void onListItemClick(ListView l, View v, int position, long id) {
    Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);

    Integer index = (Integer) map.get(KEY_INDEX);

    if(appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
        SharedPreferences prefs = getSharedPreferences(WIDGET_PREFS, 0);
        SharedPreferences.Editor edit = prefs.edit();
        edit.putInt(getPrefsKey(appWidgetId), index);
        edit.commit();
        
        
        Intent resultValue = new Intent();
        resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                        appWidgetId);
        setResult(RESULT_OK, resultValue);
        
        ShortcutWidgetProvider.updateWidget(this);
        
        finish();
    }else {
        Log.w(THIS_FILE, "Invalid widget ID here...");
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:26,代码来源:ShortcutWidgetConfigure.java

示例4: onReceive

/**
   * Receives and processes a button pressed intent or state change.
   *
   * @param context
   * @param intent  Indicates the pressed button.
   */
  @Override
  public void onReceive(final Context context, Intent intent) {
      String act = intent.getAction();
if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(act)) {
	final int appWidgetId = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
	if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
		this.onDeleted(context, new int[] { appWidgetId });
	}
} else if (SipManager.ACTION_SIP_REGISTRATION_CHANGED.equals(act) || SipManager.ACTION_SIP_ACCOUNT_CHANGED.equals(act)) {
		//Thread t = new Thread() {
		//	public void run() {
				updateWidget(context);
		//	};
		//};
		//t.start();
}
super.onReceive(context, intent);

  }
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:25,代码来源:AccountWidgetProvider.java

示例5: onReceive

/**
   * Receives and processes a button pressed intent or state change.
   *
   * @param context
   * @param intent  Indicates the pressed button.
   */
  @Override
  public void onReceive(final Context context, Intent intent) {
      String act = intent.getAction();
if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(act)) {
	final int appWidgetId = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
	if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
		this.onDeleted(context, new int[] { appWidgetId });
	}
}
super.onReceive(context, intent);

  }
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:18,代码来源:ShortcutWidgetProvider.java

示例6: onAccountClicked

@Override
public void onAccountClicked(long accountId, String d, String w) {

    if(appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
        SharedPreferences prefs = getSharedPreferences(WIDGET_PREFS, 0);
        SharedPreferences.Editor edit = prefs.edit();
        edit.putLong(getPrefsKey(appWidgetId), accountId);
        edit.commit();
        
        
        Intent resultValue = new Intent();
        resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
                        appWidgetId);
        setResult(RESULT_OK, resultValue);
        
        AccountWidgetProvider.updateWidget(this);
        
        finish();
    }else {
        Log.w(THIS_FILE, "Invalid widget ID here...");
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:22,代码来源:AccountWidgetConfigure.java

示例7: updateWidget

static boolean updateWidget(Context context, int widgetId, String path) {
    if (TextUtils.isEmpty(path) || widgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
        return false;
    }
    String name = PFiles.getNameWithoutExtension(path);
    int requestCode = ScriptWidgets.getRequestCodeForAppWidgetId(widgetId);
    Log.d(LOG_TAG, "updateWidget: id = " + widgetId + ", requestCode = " + requestCode + ", path = " + path);
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_script_shortcut);
    views.setOnClickPendingIntent(R.id.widget, PendingIntent.getActivity(context, requestCode,
            new Intent(context, RunIntentActivity.class)
                    .putExtra(ScriptIntents.EXTRA_KEY_PATH, path)
                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_UPDATE_CURRENT));
    views.setTextViewText(R.id.name, name);
    appWidgetManager.updateAppWidget(widgetId, views);
    ScriptWidgets.setPathForAppWidgetId(widgetId, path);
    return true;
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:18,代码来源:ScriptWidget.java

示例8: onStartCommand

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.d(TAG, "onStartCommand()");

    if(intent != null) {
        //Try to get extras
        String screenState = intent.getStringExtra(ScreenReceiver.SCREEN_STATE);
        int widgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);

        //Check if intent is coming from ScreenReceiver
        if(screenState != null)
            handleScreenState(screenState);

        //Check if intent came from a Widget click
        else if (widgetId != AppWidgetManager.INVALID_APPWIDGET_ID)
            handleWidgetClick(widgetId);

        else
            Log.d(TAG, "Error: Got an unknown onStartCommand() in PingWidgetUpdateService");
    }

    // If service get killed, after returning from here, restart
    return START_STICKY;
}
 
开发者ID:abicelis,项目名称:PingWidget,代码行数:24,代码来源:PingWidgetUpdateService.java

示例9: getAppWidgetIdFromIntent

private int getAppWidgetIdFromIntent() {
    Intent arrivedIntent = getIntent();
    if (arrivedIntent.getExtras() != null) {
         return arrivedIntent.getExtras().getInt(
                AppWidgetManager.EXTRA_APPWIDGET_ID,
                AppWidgetManager.INVALID_APPWIDGET_ID);
    }

    return AppWidgetManager.INVALID_APPWIDGET_ID;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:10,代码来源:TodoListAppWidgetConfigure.java

示例10: processExtras

private void processExtras(Bundle extras) {
    if (extras != null) {
        appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
                AppWidgetManager.INVALID_APPWIDGET_ID);
    }
    if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
        finish();
    }
}
 
开发者ID:ecarrara-araujo,项目名称:yabaking,代码行数:9,代码来源:IngredientsWidgetProviderConfigurationActivity.java

示例11: onCreate

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Set the result to CANCELED.  This will cause the widget host to cancel
    // out of the widget placement if the user presses the back button.
    setResult(RESULT_CANCELED);

    setContentView(R.layout.git_hub_journey_widget_configure);
    mAppWidgetText = (EditText) findViewById(R.id.appwidget_text);
    findViewById(R.id.add_button).setOnClickListener(mOnClickListener);

    // Find the widget id from the intent.
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
        mAppWidgetId = extras.getInt(
                AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    }

    // If this activity was started with an intent without an app widget ID, finish with an error.
    if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
        finish();
        return;
    }
    mAppWidgetText.setText(loadTitlePref(GitHubJourneyWidgetConfigureActivity.this, mAppWidgetId));
}
 
开发者ID:OlgaKuklina,项目名称:GitJourney,代码行数:27,代码来源:GitHubJourneyWidgetConfigureActivity.java

示例12: onCreate

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Set the result to CANCELED.  This will cause the widget host to cancel
    // out of the widget placement if the user presses the back button.
    setResult(RESULT_CANCELED);

    // Find the widget id from the intent.

    mBinding = DataBindingUtil.setContentView(this, R.layout.recipe_ingredients_widget_configure);

    recipeSpinnerAdapter = new RecipeSpinnerAdapter(this, this);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    mBinding.rvRecipeChoices.setLayoutManager(layoutManager);
    mBinding.rvRecipeChoices.setAdapter(recipeSpinnerAdapter);
    recipeDatabaseHelper = new RecipeDatabaseHelper(this);
    recipeDatabaseHelper.getAllRecipes(this);
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
        mAppWidgetId = extras.getInt(
                AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    }

    // If this activity was started with an intent without an app widget ID, finish with an error.
    if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
        finish();
        return;
    }
}
 
开发者ID:harrynp,项目名称:BakingApp,代码行数:31,代码来源:RecipeIngredientsWidgetConfigureActivity.java

示例13: notifyResult

private void notifyResult(int resultCode) {
    if (mAppWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
        // Normal case : set the result and provide back the widget id
        Intent intent = new Intent();
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
        setResult(resultCode, intent);
    }
    else {
        // Error, unknown widget id => just set the result code
        setResult(resultCode);
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:12,代码来源:VideoWidgetConfigure.java

示例14: onCreate

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Set the result to CANCELED.  This will cause the widget host to cancel
    // out of the widget placement if the user presses the back button.
    setResult(RESULT_CANCELED);

    setContentView(R.layout.hi_app_widget_configure);
    mAppWidgetText = (EditText) findViewById(R.id.appwidget_text);
    findViewById(R.id.add_button).setOnClickListener(mOnClickListener);

    // Find the widget id from the intent.
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
        mAppWidgetId = extras.getInt(
                AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    }

    // If this activity was started with an intent without an app widget ID, finish with an error.
    if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
        finish();
        return;
    }

    mAppWidgetText.setText(loadTitlePref(HiAppWidgetConfigureActivity.this, mAppWidgetId));
}
 
开发者ID:UTN-FRBA-Mobile,项目名称:Clases-2017c1,代码行数:28,代码来源:HiAppWidgetConfigureActivity.java

示例15: delete

@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    createDbIfNotExists();
    SqlArguments args = new SqlArguments(uri, selection, selectionArgs);

    SQLiteDatabase db = mOpenHelper.getWritableDatabase();

    if (Binder.getCallingPid() != Process.myPid()
            && Favorites.TABLE_NAME.equalsIgnoreCase(args.table)) {
        String widgetSelection = TextUtils.isEmpty(args.where) ? "1=1" : args.where;
        widgetSelection = String.format(Locale.ENGLISH, "%1$s = %2$d AND ( %3$s )",
                Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_APPWIDGET, widgetSelection);
        try (Cursor c = db.query(Favorites.TABLE_NAME, new String[] { Favorites.APPWIDGET_ID },
                widgetSelection, args.args, null, null, null)) {
            AppWidgetHost host = new AppWidgetHost(getContext(), Launcher.APPWIDGET_HOST_ID);
            while (c.moveToNext()) {
                int widgetId = c.getInt(0);
                if (widgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
                    try {
                        host.deleteAppWidgetId(widgetId);
                    } catch (RuntimeException e) {
                        Log.e(TAG, "Error deleting widget id " + widgetId, e);
                    }
                }
            }
        }
    }
    int count = db.delete(args.table, args.where, args.args);
    if (count > 0) {
        notifyListeners();
        reloadLauncherIfExternal();
    }
    return count;
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:34,代码来源:LauncherProvider.java


注:本文中的android.appwidget.AppWidgetManager.INVALID_APPWIDGET_ID属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。