List of usage examples for android.content ComponentName ComponentName
private ComponentName(String pkg, Parcel in)
From source file:android.content.ContextImpl.java
public ContextImpl(String _name) { this.name = new ComponentName(_name, _name); this.intentReslover = IntentResolver.getInstance(); }
From source file:com.concentriclivers.mms.com.android.mms.widget.MmsWidgetProvider.java
@Override public void onReceive(Context context, Intent intent) { // if (Log.isLoggable(LogTag.WIDGET, Log.VERBOSE)) { Log.v(TAG, "onReceive intent: " + intent); // }/*from ww w. ja va2 s .c o m*/ String action = intent.getAction(); // The base class AppWidgetProvider's onReceive handles the normal widget intents. Here // we're looking for an intent sent by the messaging app when it knows a message has // been sent or received (or a conversation has been read) and is telling the widget it // needs to update. if (ACTION_NOTIFY_DATASET_CHANGED.equals(action)) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] appWidgetIds = appWidgetManager .getAppWidgetIds(new ComponentName(context, MmsWidgetProvider.class)); if (appWidgetIds.length > 0) { appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds[0], R.id.conversation_list); } } else { super.onReceive(context, intent); } }
From source file:com.tonikorin.cordova.plugin.autostart.AutoStart.java
private void setAutoStart(boolean enabled) { Context context = cordova.getActivity().getApplicationContext(); int componentState; SharedPreferences sp = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); if (enabled) { componentState = PackageManager.COMPONENT_ENABLED_STATE_ENABLED; // Store the class name of your main activity for AppStarter editor.putString(CLASS_NAME, cordova.getActivity().getLocalClassName()); } else {/*w ww.j ava 2s . c o m*/ componentState = PackageManager.COMPONENT_ENABLED_STATE_DISABLED; editor.remove(CLASS_NAME); } editor.commit(); // Enable or Disable BootCompletedReceiver ComponentName bootCompletedReceiver = new ComponentName(context, BootCompletedReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(bootCompletedReceiver, componentState, PackageManager.DONT_KILL_APP); }
From source file:com.actionbarsherlock.internal.view.menu.ActionMenu.java
public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, android.view.MenuItem[] outSpecificItems) { PackageManager pm = mContext.getPackageManager(); final List<ResolveInfo> lri = pm.queryIntentActivityOptions(caller, specifics, intent, 0); final int N = lri != null ? lri.size() : 0; if ((flags & FLAG_APPEND_TO_GROUP) == 0) { removeGroup(groupId);/*from ww w .j a va2 s.c o m*/ } for (int i = 0; i < N; i++) { final ResolveInfo ri = lri.get(i); Intent rintent = new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]); rintent.setComponent( new ComponentName(ri.activityInfo.applicationInfo.packageName, ri.activityInfo.name)); final MenuItem item = add(groupId, itemId, order, ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)) .setIntent(rintent); if (outSpecificItems != null && ri.specificIndex >= 0) { outSpecificItems[ri.specificIndex] = item; } } return N; }
From source file:cm.aptoide.ptdev.preferences.ManagerPreferences.java
private void removeLauncherShortcut(Context context) { final Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setComponent(new ComponentName(context.getPackageName(), "cm.aptoide.ptdev.Start")); final Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, Aptoide.getConfiguration().getMarketName()); shortcutIntent.setComponent(new ComponentName(context.getPackageName(), "cm.aptoide.ptdev.Start")); intent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); context.sendBroadcast(intent, null); }
From source file:android.content.ScopedContextImpl.java
public ScopedContextImpl(String _name) { this.name = new ComponentName(_name, _name); this.intentReslover = ScopedIntentResolver.getInstance(); }
From source file:ch.ethz.dcg.jukefox.commons.utils.AndroidUtils.java
public static int getVersionCode() { try {/*from w ww .j a v a2 s . co m*/ Context context = JukefoxApplication.getAppContext(); ComponentName comp = new ComponentName(context, JukefoxApplication.class); PackageInfo pinfo = context.getPackageManager().getPackageInfo(comp.getPackageName(), 0); return pinfo.versionCode; } catch (android.content.pm.PackageManager.NameNotFoundException e) { return -1; } }
From source file:com.chexiaoya.gaodemapdemo.SpeechSearchActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search_activity_layout); ButterKnife.bind(this); speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this, new ComponentName(this, VoiceRecognitionService.class)); speechRecognizer.setRecognitionListener(this); getDatas();//from w ww . j a va 2 s . c om /** ? */ mResultText.addTextChangedListener(this); }
From source file:com.example.android.AudioArchive.ui.BaseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LogHelper.d(TAG, "Activity onCreate"); if (Build.VERSION.SDK_INT >= 21) { // Since our app icon has the same color as colorPrimary, our entry in the Recent Apps // list gets weird. We need to change either the icon or the color // of the TaskDescription. ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getTitle().toString(), BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_white), ResourceHelper.getThemeColor(this, R.attr.colorPrimary, android.R.color.darker_gray)); setTaskDescription(taskDesc);// ww w. j a va2 s .co m } // Connect a media browser just to get the media session token. There are other ways // this can be done, for example by sharing the session token directly. mMediaBrowser = new MediaBrowserCompat(this, new ComponentName(this, MusicService.class), mConnectionCallback, null); }
From source file:com.commonsware.android.advservice.remotebinding.sigcheck.DownloadFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true);//from w w w . j a v a 2s.co m appContext = (Application) getActivity().getApplicationContext(); Intent implicit = new Intent(IDownload.class.getName()); List<ResolveInfo> matches = getActivity().getPackageManager().queryIntentServices(implicit, 0); if (matches.size() == 0) { Toast.makeText(getActivity(), "Cannot find a matching service!", Toast.LENGTH_LONG).show(); } else if (matches.size() > 1) { Toast.makeText(getActivity(), "Found multiple matching services!", Toast.LENGTH_LONG).show(); } else { ServiceInfo svcInfo = matches.get(0).serviceInfo; try { String otherHash = SignatureUtils.getSignatureHash(getActivity(), svcInfo.applicationInfo.packageName); String expected = getActivity().getString(R.string.expected_sig_hash); if (expected.equals(otherHash)) { Intent explicit = new Intent(implicit); ComponentName cn = new ComponentName(svcInfo.applicationInfo.packageName, svcInfo.name); explicit.setComponent(cn); appContext.bindService(explicit, this, Context.BIND_AUTO_CREATE); } else { Toast.makeText(getActivity(), "Unexpected signature found!", Toast.LENGTH_LONG).show(); } } catch (Exception e) { Log.e(getClass().getSimpleName(), "Exception trying to get signature hash", e); } } }