List of usage examples for android.content ComponentName ComponentName
private ComponentName(String pkg, Parcel in)
From source file:com.lee.sdk.utils.Utils.java
/** * component??// w w w.j ava2 s. co m * * @param ctx context * @param className class name * @return ?? */ public static boolean isComponentEnable(Context ctx, String className) { PackageManager pm = ctx.getPackageManager(); ComponentName cn = new ComponentName(ctx.getPackageName(), className); int ret = pm.getComponentEnabledSetting(cn); if (ret == PackageManager.COMPONENT_ENABLED_STATE_ENABLED || ret == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) { return true; } return false; }
From source file:com.cw.litenote.main.MainAct.java
void doCreate(Bundle savedInstanceState) { System.out.println("MainAct / _doCreate"); // Will create default contents: by assets or by initial tables if (Pref.getPref_will_create_default_content(this)) { if (Define.DEFAULT_CONTENT == Define.BY_ASSETS) createDefaultContent_byAssets(); else if ((Define.DEFAULT_CONTENT == Define.BY_INITIAL_TABLES) && (Define.INITIAL_FOLDERS_COUNT > 0)) createDefaultContent_byInitialTables(); }//from ww w . j av a2s. co m mFolderTitles = new ArrayList<>(); // Context context = getApplicationContext(); //Add note with the link which got from other App String intentLink = mMainUi.addNote_IntentLink(getIntent(), mAct); if (!Util.isEmptyString(intentLink)) { finish(); // LiteNote not running at first, keep closing return; } else { // check DB final boolean ENABLE_DB_CHECK = false;//true;//false if (ENABLE_DB_CHECK) { // list all folder tables FolderUi.listAllFolderTables(mAct); // recover focus DB_folder.setFocusFolder_tableId(Pref.getPref_focusView_folder_tableId(this)); DB_page.setFocusPage_tableId(Pref.getPref_focusView_page_tableId(this)); } //if(ENABLE_DB_CHECK) // get focus folder table Id, default folder table Id: 1 DB_drawer dB_drawer = new DB_drawer(this); dB_drawer.open(); if (savedInstanceState == null) { for (int i = 0; i < dB_drawer.getFoldersCount(false); i++) { if (dB_drawer.getFolderTableId(i, false) == Pref.getPref_focusView_folder_tableId(this)) { FolderUi.setFocus_folderPos(i); System.out.println("MainAct / _mainAction / FolderUi.getFocus_folderPos() = " + FolderUi.getFocus_folderPos()); } } Audio_manager.setPlayerState(Audio_manager.PLAYER_AT_STOP); } dB_drawer.close(); // enable ActionBar app icon to behave as action to toggle nav drawer // getActionBar().setDisplayHomeAsUpEnabled(true); // getActionBar().setHomeButtonEnabled(true); // getActionBar().setBackgroundDrawable(new ColorDrawable(ColorSet.getBarColor(mAct))); mContext = getBaseContext(); // add on back stack changed listener mFragmentManager = getSupportFragmentManager(); mOnBackStackChangedListener = this; mFragmentManager.addOnBackStackChangedListener(mOnBackStackChangedListener); } isAddedOnNewIntent = false; // Register Bluetooth device receiver if (Build.VERSION.SDK_INT < 21) { IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED); this.registerReceiver(bluetooth_device_receiver, filter); } else // if(Build.VERSION.SDK_INT >= 21) { // Media session: to receive media button event of bluetooth device // new media browser instance and create BackgroundAudioService instance: support notification if (mMediaBrowserCompat == null) { mMediaBrowserCompat = new MediaBrowserCompat(mAct, new ComponentName(mAct, BackgroundAudioService.class), mMediaBrowserCompatConnectionCallback, mAct.getIntent().getExtras()); if (!mMediaBrowserCompat.isConnected()) mMediaBrowserCompat.connect();//cf: https://stackoverflow.com/questions/43169875/mediabrowser-subscribe-doesnt-work-after-i-get-back-to-activity-1-from-activity mCurrentState = STATE_PAUSED; } } // init audio parameters MainAct.mPlaying_folderPos = -1; Audio_manager.setPlayerState(Audio_manager.PLAYER_AT_STOP); TabsHost.audioPlayTabPos = -1; }
From source file:com.air.mobilebrowser.BrowserActivity.java
/** * Clear the setting for default home.//from ww w . j a v a 2 s . c o m */ private void clearHome() { PackageManager pm = getPackageManager(); ComponentName fauxHomeComponent = new ComponentName(getApplicationContext(), FauxHome.class); ComponentName homeComponent = new ComponentName(getApplicationContext(), BrowserActivity.class); pm.setComponentEnabledSetting(fauxHomeComponent, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(homeComponent, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(fauxHomeComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(homeComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
From source file:com.andrew.apolloMod.service.ApolloService.java
@SuppressLint({ "WorldWriteableFiles", "WorldReadableFiles" }) @Override// w ww .ja va2s .c om public void onCreate() { super.onCreate(); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); ComponentName rec = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName()); mAudioManager.registerMediaButtonEventReceiver(rec); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(rec); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, PendingIntent.FLAG_UPDATE_CURRENT); if (Constants.isApi14Supported()) { mRemoteControlClient = new RemoteControlClient(mediaPendingIntent); mAudioManager.registerRemoteControlClient(mRemoteControlClient); int flags = RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP; mRemoteControlClient.setTransportControlFlags(flags); } mPreferences = getSharedPreferences(APOLLO_PREFERENCES, MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE); mCardId = MusicUtils.getCardId(this); registerExternalStorageListener(); // Needs to be done in this thread, since otherwise // ApplicationContext.getPowerManager() crashes. mPlayer = new MultiPlayer(); mPlayer.setHandler(mMediaplayerHandler); reloadQueue(); notifyChange(QUEUE_CHANGED); notifyChange(META_CHANGED); IntentFilter commandFilter = new IntentFilter(); commandFilter.addAction(SERVICECMD); commandFilter.addAction(TOGGLEPAUSE_ACTION); commandFilter.addAction(PAUSE_ACTION); commandFilter.addAction(NEXT_ACTION); commandFilter.addAction(PREVIOUS_ACTION); commandFilter.addAction(CYCLEREPEAT_ACTION); commandFilter.addAction(TOGGLESHUFFLE_ACTION); registerReceiver(mIntentReceiver, commandFilter); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName()); mWakeLock.setReferenceCounted(false); // If the service was idle, but got killed before it stopped itself, the // system will relaunch it. Make sure it gets stopped again in that // case. Message msg = mDelayedStopHandler.obtainMessage(); mDelayedStopHandler.sendMessageDelayed(msg, IDLE_DELAY); }
From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java
public void onBackPressed() { if (widgetFirstTimeSetup) { finishWidgetSetup();// www . j a va2 s .c o m return; } // check if sort has changed if (needsFeedUpdate || needsFeedViewUpdate || needsThemeUpdate) { if (mAppWidgetId != 0) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(SubredditSelectActivity.this); RemoteViews views = new RemoteViews(getPackageName(), R.layout.widget); views.setViewVisibility(R.id.srloader, View.VISIBLE); views.setViewVisibility(R.id.erroricon, View.INVISIBLE); // bypass the cached entrys only if the sorting preference has changed if (needsFeedUpdate) { global.setBypassCache(true); } else { global.setRefreshView(); } if (needsThemeUpdate) { WidgetProvider.updateAppWidgets(SubredditSelectActivity.this, appWidgetManager, new int[] { mAppWidgetId }, false); } else { appWidgetManager.partiallyUpdateAppWidget(mAppWidgetId, views); } appWidgetManager.notifyAppWidgetViewDataChanged(mAppWidgetId, R.id.listview); } else { Intent intent = new Intent(); intent.putExtra("themeupdate", needsThemeUpdate); if (needsFeedUpdate) { setResult(2, intent); // reload feed and prefs } else { setResult(1, intent); // tells main activity to update feed prefs } if (needsThemeUpdate) { global.setRefreshView(); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(SubredditSelectActivity.this); int[] widgetIds = appWidgetManager .getAppWidgetIds(new ComponentName(SubredditSelectActivity.this, WidgetProvider.class)); WidgetProvider.updateAppWidgets(SubredditSelectActivity.this, appWidgetManager, widgetIds, false); appWidgetManager.notifyAppWidgetViewDataChanged(widgetIds, R.id.listview); } } } else { setResult(0); } finish(); }
From source file:com.cw.litenote.note.Note.java
@Override protected void onResume() { super.onResume(); System.out.println("Note / _onResume"); setLayoutView();//from w w w .ja v a 2 s. c om isPagerActive = true; if (canShowFullScreenPicture()) Note.setPictureMode(); else Note.setViewAllMode(); setOutline(act); // Register Bluetooth device receiver if (Build.VERSION.SDK_INT < 21) { IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED); this.registerReceiver(mReceiver, filter); } else // Build.VERSION.SDK_INT >= 21 { // Media session: to receive media button event of bluetooth device // new media browser instance and create BackgroundAudioService instance: support notification if (MainAct.mMediaBrowserCompat == null) { MainAct.mMediaBrowserCompat = new MediaBrowserCompat(act, new ComponentName(act, BackgroundAudioService.class), MainAct.mMediaBrowserCompatConnectionCallback, act.getIntent().getExtras()); } if (!MainAct.mMediaBrowserCompat.isConnected()) MainAct.mMediaBrowserCompat.connect(); MainAct.mCurrentState = MainAct.STATE_PAUSED; } }
From source file:com.actionbarsherlock.internal.view.menu.MenuBuilder.java
public int addIntentOptions(int group, int id, int categoryOrder, 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(group);/* w w w .ja v a 2 s.co 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(group, id, categoryOrder, ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)) .setIntent(rintent); if (outSpecificItems != null && ri.specificIndex >= 0) { outSpecificItems[ri.specificIndex] = item; } } return N; }
From source file:android.support.v7.internal.widget.ActivityChooserModel.java
/** * Sets the default activity. The default activity is set by adding a * historical record with weight high enough that this activity will * become the highest ranked. Such a strategy guarantees that the default * will eventually change if not used. Also the weight of the record for * setting a default is inflated with a constant amount to guarantee that * it will stay as default for awhile.// w w w.j a v a 2 s . co m * * @param index The index of the activity to set as default. */ public void setDefaultActivity(int index) { synchronized (mInstanceLock) { ensureConsistentState(); ActivityResolveInfo newDefaultActivity = mActivities.get(index); ActivityResolveInfo oldDefaultActivity = mActivities.get(0); final float weight; if (oldDefaultActivity != null) { // Add a record with weight enough to boost the chosen at the top. weight = oldDefaultActivity.weight - newDefaultActivity.weight + DEFAULT_ACTIVITY_INFLATION; } else { weight = DEFAULT_HISTORICAL_RECORD_WEIGHT; } ComponentName defaultName = new ComponentName(newDefaultActivity.resolveInfo.activityInfo.packageName, newDefaultActivity.resolveInfo.activityInfo.name); HistoricalRecord historicalRecord = new HistoricalRecord(defaultName, System.currentTimeMillis(), weight); addHisoricalRecord(historicalRecord); } }
From source file:com.air.mobilebrowser.BrowserActivity.java
/** * Cleanup everything that was changed./*from w ww. j ava 2s . c om*/ */ public void cleanup() { stopService(new Intent(getApplicationContext(), ActivityWatchService.class)); //clear home and exit PackageManager pm = getPackageManager(); ComponentName fauxHomeComponent = new ComponentName(getApplicationContext(), FauxHome.class); ComponentName homeComponent = new ComponentName(getApplicationContext(), BrowserActivity.class); pm.setComponentEnabledSetting(fauxHomeComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(homeComponent, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); mAudioManager.setMicrophoneMute(OrigSettings.getInstance().isMicMuted()); String curKeyboard = KeyboardUtil.getKeyboardPackage(BrowserActivity.this.getContentResolver()); if (!curKeyboard.equals(OrigSettings.getInstance().getKeyboard())) { KeyboardUtil.showInputChangedExitDialog(this, new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { finish(); } }); } else { finish(); } }