Java Code Examples for android.content.Intent#getIntArrayExtra()
The following examples show how to use
android.content.Intent#getIntArrayExtra() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeolocationModule.java From incubator-weex-playground with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { int code = intent.getIntExtra(ILocatable.REQUEST_PERMISSION_CODE, 0); int[] grantResults = intent.getIntArrayExtra("grantResults"); if (code == ILocatable.REQUEST_CUR_PERMISSION_CODE) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { mLocatable.getCurrentPosition(mSuccessCallback, mErrorCallback, mParams); } else { noPermission(); } } else if (code == ILocatable.REQUEST_WATCH_PERMISSION_CODE) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { mLocatable.watchPosition(mSuccessCallback, mErrorCallback, mParams); } else { noPermission(); } } LocalBroadcastManager.getInstance(context).unregisterReceiver(this); }
Example 2
Source File: StayAwakeTile.java From GravityBox with Apache License 2.0 | 6 votes |
@Override public void onBroadcastReceived(Context context, Intent intent) { super.onBroadcastReceived(context, intent); if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_QUICKSETTINGS_CHANGED)) { if (intent.hasExtra(GravityBoxSettings.EXTRA_SA_MODE)) { int[] modes = intent.getIntArrayExtra(GravityBoxSettings.EXTRA_SA_MODE); if (DEBUG) log(getKey() + ": onBroadcastReceived: modes=" + modes); updateSettings(modes); } if (intent.hasExtra(GravityBoxSettings.EXTRA_SA_QUICK_MODE)) { mQuickMode = intent.getBooleanExtra(GravityBoxSettings.EXTRA_SA_QUICK_MODE, false); } if (intent.hasExtra(GravityBoxSettings.EXTRA_SA_AUTO_RESET)) { mAutoReset = intent.getBooleanExtra(GravityBoxSettings.EXTRA_SA_AUTO_RESET, false); } } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { if (mAutoReset && mDefaultTimeout > 0) { setScreenOffTimeout(mDefaultTimeout); } mDefaultTimeout = 0; if (DEBUG) log(getKey() + ": screen turned off"); } }
Example 3
Source File: DoNotDisturbTile.java From GravityBox with Apache License 2.0 | 6 votes |
@Override public void onBroadcastReceived(Context context, Intent intent) { if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_QUICKSETTINGS_CHANGED)) { if (intent.hasExtra(GravityBoxSettings.EXTRA_DND_TILE_QUICK_MODE)) { mQuickMode = intent.getBooleanExtra(GravityBoxSettings.EXTRA_DND_TILE_QUICK_MODE, false); } if (intent.hasExtra(GravityBoxSettings.EXTRA_DND_TILE_ENABLED_MODES)) { int[] modes = intent.getIntArrayExtra(GravityBoxSettings.EXTRA_DND_TILE_ENABLED_MODES); if (DEBUG) log(getKey() + ": onBroadcastReceived: modes=" + Arrays.toString(modes)); setEnabledModes(modes); } if (intent.hasExtra(GravityBoxSettings.EXTRA_DND_TILE_DURATION_MODE)) { mDurationMode = DurationMode.valueOf(intent.getStringExtra( GravityBoxSettings.EXTRA_DND_TILE_DURATION_MODE)); } if (intent.hasExtra(GravityBoxSettings.EXTRA_DND_TILE_DURATION)) { mDuration = intent.getIntExtra(GravityBoxSettings.EXTRA_DND_TILE_DURATION, 60); } } super.onBroadcastReceived(context, intent); }
Example 4
Source File: MusicService.java From VinylMusicPlayer with GNU General Public License v3.0 | 6 votes |
@Override public void onReceive(final Context context, final Intent intent) { final String command = intent.getStringExtra(EXTRA_APP_WIDGET_NAME); final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); switch (command) { case AppWidgetClassic.NAME: { appWidgetClassic.performUpdate(MusicService.this, ids); break; } case AppWidgetSmall.NAME: { appWidgetSmall.performUpdate(MusicService.this, ids); break; } case AppWidgetBig.NAME: { appWidgetBig.performUpdate(MusicService.this, ids); break; } case AppWidgetCard.NAME: { appWidgetCard.performUpdate(MusicService.this, ids); break; } } }
Example 5
Source File: WXCompatModule.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); switch (action) { case WXModule.ACTION_ACTIVITY_RESULT: int requestCode = intent.getIntExtra(WXModule.REQUEST_CODE, -1); int resultCode = intent.getIntExtra(WXModule.RESULT_CODE, Activity.RESULT_OK); mWXCompatModule.onActivityResult(requestCode, resultCode, intent); break; case WXModule.ACTION_REQUEST_PERMISSIONS_RESULT: requestCode = intent.getIntExtra(WXModule.REQUEST_CODE, -1); String[] permissions = intent.getStringArrayExtra(WXModule.PERMISSIONS); int[] grantResults = intent.getIntArrayExtra(WXModule.GRANT_RESULTS); mWXCompatModule.onRequestPermissionsResult(requestCode, permissions, grantResults); break; } }
Example 6
Source File: AppWidgetsRestoredReceiver.java From LaunchEnr with GNU General Public License v3.0 | 6 votes |
@Override public void onReceive(final Context context, Intent intent) { if (AppWidgetManager.ACTION_APPWIDGET_HOST_RESTORED.equals(intent.getAction())) { final int[] oldIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_OLD_IDS); final int[] newIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); if (oldIds.length == newIds.length) { final PendingResult asyncResult = goAsync(); new Handler(LauncherModel.getWorkerLooper()) .postAtFrontOfQueue(new Runnable() { @Override public void run() { restoreAppWidgetIds(context, asyncResult, oldIds, newIds); } }); } } }
Example 7
Source File: MusicService.java From Phonograph with GNU General Public License v3.0 | 6 votes |
@Override public void onReceive(final Context context, final Intent intent) { final String command = intent.getStringExtra(EXTRA_APP_WIDGET_NAME); final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); switch (command) { case AppWidgetClassic.NAME: { appWidgetClassic.performUpdate(MusicService.this, ids); break; } case AppWidgetSmall.NAME: { appWidgetSmall.performUpdate(MusicService.this, ids); break; } case AppWidgetBig.NAME: { appWidgetBig.performUpdate(MusicService.this, ids); break; } case AppWidgetCard.NAME: { appWidgetCard.performUpdate(MusicService.this, ids); break; } } }
Example 8
Source File: NetworkModeTile.java From GravityBox with Apache License 2.0 | 5 votes |
@Override public void onBroadcastReceived(Context context, Intent intent) { super.onBroadcastReceived(context, intent); if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_QUICKSETTINGS_CHANGED)) { if (intent.hasExtra(GravityBoxSettings.EXTRA_NM_TILE_ENABLED_MODES)) { int[] modes = intent.getIntArrayExtra(GravityBoxSettings.EXTRA_NM_TILE_ENABLED_MODES); if (DEBUG) log(getKey() + ": onBroadcastReceived: modes=" + Arrays.toString(modes)); setEnabledModes(modes); } if (intent.hasExtra(GravityBoxSettings.EXTRA_NM_TILE_QUICK_MODE)) { mQuickMode = intent.getBooleanExtra(GravityBoxSettings.EXTRA_NM_TILE_QUICK_MODE, false); } } if (intent.getAction().equals(PhoneWrapper.ACTION_NETWORK_TYPE_CHANGED)) { String tag = intent.getStringExtra(PhoneWrapper.EXTRA_RECEIVER_TAG); if (tag == null || tag.equals(TAG)) { int phoneId = intent.getIntExtra(PhoneWrapper.EXTRA_PHONE_ID, 0); if (phoneId == mSimSlot) { mNetworkType = intent.getIntExtra(PhoneWrapper.EXTRA_NETWORK_TYPE, PhoneWrapper.getDefaultNetworkType()); if (DEBUG) log(getKey() + ": ACTION_NETWORK_TYPE_CHANGED: mNetworkType = " + mNetworkType); if (mIsReceiving) { refreshState(); } } } } if (mIsMsim && intent.getAction().equals( GravityBoxSettings.ACTION_PREF_QS_NETWORK_MODE_SIM_SLOT_CHANGED)) { mSimSlot = intent.getIntExtra(GravityBoxSettings.EXTRA_SIM_SLOT, 0); if (DEBUG) log(getKey() + ": received ACTION_PREF_QS_NETWORK_MODE_SIM_SLOT_CHANGED broadcast: " + "mSimSlot = " + mSimSlot); } }
Example 9
Source File: MusicService.java From Music-Player with GNU General Public License v3.0 | 5 votes |
@Override public void onReceive(final Context context, final Intent intent) { final String command = intent.getStringExtra(EXTRA_APP_WIDGET_NAME); final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); switch (command) { case AppWidgetClassic.NAME: { appWidgetClassic.performUpdate(MusicService.this, ids); break; } case AppWidgetClassicDark.NAME: { appWidgetClassicDark.performUpdate(MusicService.this, ids); break; } case AppWidgetSmall.NAME: { appWidgetSmall.performUpdate(MusicService.this, ids); break; } case AppWidgetSmallDark.NAME: { appWidgetSmallDark.performUpdate(MusicService.this, ids); break; } case AppWidgetBig.NAME: { appWidgetBig.performUpdate(MusicService.this, ids); break; } case AppWidgetCard.NAME: { appWidgetCard.performUpdate(MusicService.this, ids); break; } case AppWidgetCardDark.NAME: { appWidgetCardDark.performUpdate(MusicService.this, ids); break; } } }
Example 10
Source File: AppWidgetsRestoredReceiver.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (AppWidgetManager.ACTION_APPWIDGET_HOST_RESTORED.equals(intent.getAction())) { int[] oldIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_OLD_IDS); int[] newIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); if (oldIds.length == newIds.length) { restoreAppWidgetIds(context, oldIds, newIds); } else { Log.e(TAG, "Invalid host restored received"); } } }
Example 11
Source File: MediaPlaybackService.java From coursera-android with MIT License | 5 votes |
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); String cmd = intent.getStringExtra("command"); MusicUtils.debugLog("mIntentReceiver.onReceive " + action + " / " + cmd); if (CMDNEXT.equals(cmd) || NEXT_ACTION.equals(action)) { gotoNext(true); } else if (CMDPREVIOUS.equals(cmd) || PREVIOUS_ACTION.equals(action)) { prev(); } else if (CMDTOGGLEPAUSE.equals(cmd) || TOGGLEPAUSE_ACTION.equals(action)) { if (isPlaying()) { pause(); mPausedByTransientLossOfFocus = false; } else { play(); } } else if (CMDPAUSE.equals(cmd) || PAUSE_ACTION.equals(action)) { pause(); mPausedByTransientLossOfFocus = false; } else if (CMDPLAY.equals(cmd)) { play(); } else if (CMDSTOP.equals(cmd)) { pause(); mPausedByTransientLossOfFocus = false; seek(0); } else if (MediaAppWidgetProvider.CMDAPPWIDGETUPDATE.equals(cmd)) { // Someone asked us to refresh a set of specific widgets, probably // because they were just added. int[] appWidgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); mAppWidgetProvider.performUpdate(MediaPlaybackService.this, appWidgetIds); } }
Example 12
Source File: AudioCapabilities.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@SuppressLint("InlinedApi") /* package */ static AudioCapabilities getCapabilities(Context context, @Nullable Intent intent) { if (deviceMaySetExternalSurroundSoundGlobalSetting() && Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) { return EXTERNAL_SURROUND_SOUND_CAPABILITIES; } if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) { return DEFAULT_AUDIO_CAPABILITIES; } return new AudioCapabilities( intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS), intent.getIntExtra( AudioManager.EXTRA_MAX_CHANNEL_COUNT, /* defaultValue= */ DEFAULT_MAX_CHANNEL_COUNT)); }
Example 13
Source File: AbstractBgFetch.java From Onosendai with Apache License 2.0 | 5 votes |
@Override protected void doWork (final Intent i) { final int[] columnIds = i.getIntArrayExtra(ARG_COLUMN_IDS); final boolean manual = i.getBooleanExtra(ARG_IS_MANUAL, false); getLog().i("%s invoked (column_ids=%s, is_manual=%b).", getClass().getSimpleName(), Arrays.toString(columnIds), manual); doWork(columnIds, manual); }
Example 14
Source File: AudioCapabilities.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@SuppressLint("InlinedApi") /* package */ static AudioCapabilities getCapabilities(@Nullable Intent intent) { if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) { return DEFAULT_AUDIO_CAPABILITIES; } return new AudioCapabilities(intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS), intent.getIntExtra(AudioManager.EXTRA_MAX_CHANNEL_COUNT, 0)); }
Example 15
Source File: RegisteredServicesCache.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@VisibleForTesting protected void handlePackageEvent(Intent intent, int userId) { // Don't regenerate the services map when the package is removed or its // ASEC container unmounted as a step in replacement. The subsequent // _ADDED / _AVAILABLE call will regenerate the map in the final state. final String action = intent.getAction(); // it's a new-component action if it isn't some sort of removal final boolean isRemoval = Intent.ACTION_PACKAGE_REMOVED.equals(action) || Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action); // if it's a removal, is it part of an update-in-place step? final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false); if (isRemoval && replacing) { // package is going away, but it's the middle of an upgrade: keep the current // state and do nothing here. This clause is intentionally empty. } else { int[] uids = null; // either we're adding/changing, or it's a removal without replacement, so // we need to update the set of available services if (Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(action) || Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) { uids = intent.getIntArrayExtra(Intent.EXTRA_CHANGED_UID_LIST); } else { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); if (uid > 0) { uids = new int[] { uid }; } } generateServicesMap(uids, userId); } }
Example 16
Source File: ClearBrowsingDataPreferences.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * This is the callback for the important domain dialog. We should only clear if we get the * positive button response. */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == IMPORTANT_SITES_DIALOG_CODE && resultCode == Activity.RESULT_OK) { // Deselected means that the user is excluding the domain from being cleared. String[] deselectedDomains = data.getStringArrayExtra( ConfirmImportantSitesDialogFragment.DESELECTED_DOMAINS_TAG); int[] deselectedDomainReasons = data.getIntArrayExtra( ConfirmImportantSitesDialogFragment.DESELECTED_DOMAIN_REASONS_TAG); String[] ignoredDomains = data.getStringArrayExtra( ConfirmImportantSitesDialogFragment.IGNORED_DOMAINS_TAG); int[] ignoredDomainReasons = data.getIntArrayExtra( ConfirmImportantSitesDialogFragment.IGNORED_DOMAIN_REASONS_TAG); if (deselectedDomains != null && mSortedImportantDomains != null) { // mMaxImportantSites is a constant on the C++ side. RecordHistogram.recordCustomCountHistogram( "History.ClearBrowsingData.ImportantDeselectedNum", deselectedDomains.length, 1, mMaxImportantSites + 1, mMaxImportantSites + 1); RecordHistogram.recordCustomCountHistogram( "History.ClearBrowsingData.ImportantIgnoredNum", ignoredDomains.length, 1, mMaxImportantSites + 1, mMaxImportantSites + 1); // We put our max at 20 instead of 100 to reduce the number of empty buckets (as // our maximum denominator is 5). RecordHistogram.recordEnumeratedHistogram( "History.ClearBrowsingData.ImportantDeselectedPercent", deselectedDomains.length * IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT / mSortedImportantDomains.length, IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT + 1); RecordHistogram.recordEnumeratedHistogram( "History.ClearBrowsingData.ImportantIgnoredPercent", ignoredDomains.length * IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT / mSortedImportantDomains.length, IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT + 1); } clearBrowsingData(getSelectedOptions(), deselectedDomains, deselectedDomainReasons, ignoredDomains, ignoredDomainReasons); } }
Example 17
Source File: ConfirmActivity.java From DeviceConnect-Android with MIT License | 5 votes |
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_linking_confirm); if (BuildConfig.DEBUG) { Log.i(TAG, "ConfirmActivity:onCreate"); } Intent intent = getIntent(); if (intent != null) { mRequestType = intent.getIntArrayExtra(EXTRA_REQUEST_SENSOR_TYPE); if (BuildConfig.DEBUG) { if (mRequestType != null) { for (int type : mRequestType) { Log.d(TAG, "RequestType: " + type); } } } } if (mRequestType == null || mRequestType.length == 0) { if (BuildConfig.DEBUG) { Log.e(TAG, "RequestType is null."); } finishConfirmActivity(); } else { startSensor(); } }
Example 18
Source File: AudioCapabilities.java From MediaSDK with Apache License 2.0 | 5 votes |
@SuppressLint("InlinedApi") /* package */ static AudioCapabilities getCapabilities(Context context, @Nullable Intent intent) { if (deviceMaySetExternalSurroundSoundGlobalSetting() && Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) { return EXTERNAL_SURROUND_SOUND_CAPABILITIES; } if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) { return DEFAULT_AUDIO_CAPABILITIES; } return new AudioCapabilities( intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS), intent.getIntExtra( AudioManager.EXTRA_MAX_CHANNEL_COUNT, /* defaultValue= */ DEFAULT_MAX_CHANNEL_COUNT)); }
Example 19
Source File: MyPreferences.java From audio-analyzer-for-android with Apache License 2.0 | 4 votes |
@Override protected void onResume() { super.onResume(); // Get list of default sources Intent intent = getIntent(); final int[] asid = intent.getIntArrayExtra(AnalyzerActivity.MYPREFERENCES_MSG_SOURCE_ID); final String[] as = intent.getStringArrayExtra(AnalyzerActivity.MYPREFERENCES_MSG_SOURCE_NAME); int nExtraSources = 0; for (int id : asid) { // See SamplingLoop::run() for the magic number 1000 if (id >= 1000) nExtraSources++; } // Get list of supported sources AnalyzerUtil au = new AnalyzerUtil(this); final int[] audioSourcesId = au.GetAllAudioSource(4); Log.i(TAG, " n_as = " + audioSourcesId.length); Log.i(TAG, " n_ex = " + nExtraSources); audioSourcesName = new String[audioSourcesId.length + nExtraSources]; for (int i = 0; i < audioSourcesId.length; i++) { audioSourcesName[i] = au.getAudioSourceName(audioSourcesId[i]); } // Combine these two sources audioSources = new String[audioSourcesName.length]; int j = 0; for (; j < audioSourcesId.length; j++) { audioSources[j] = String.valueOf(audioSourcesId[j]); } for (int i = 0; i < asid.length; i++) { // See SamplingLoop::run() for the magic number 1000 if (asid[i] >= 1000) { audioSources[j] = String.valueOf(asid[i]); audioSourcesName[j] = as[i]; j++; } } final ListPreference lp = (ListPreference) findPreference("audioSource"); lp.setDefaultValue(MediaRecorder.AudioSource.VOICE_RECOGNITION); lp.setEntries(audioSourcesName); lp.setEntryValues(audioSources); getPreferenceScreen().getSharedPreferences() .registerOnSharedPreferenceChangeListener(prefListener); }
Example 20
Source File: UpdateWidgetService.java From codeexamples-android with Eclipse Public License 1.0 | 4 votes |
@Override public void onStart(Intent intent, int startId) { Log.i(LOG, "Called"); // Create some random data AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this .getApplicationContext()); int[] allWidgetIds = intent .getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); ComponentName thisWidget = new ComponentName(getApplicationContext(), MyWidgetProvider.class); int[] allWidgetIds2 = appWidgetManager.getAppWidgetIds(thisWidget); Log.w(LOG, "From Intent" + String.valueOf(allWidgetIds.length)); Log.w(LOG, "Direct" + String.valueOf(allWidgetIds2.length)); for (int widgetId : allWidgetIds) { // Create some random data int number = (new Random().nextInt(100)); RemoteViews remoteViews = new RemoteViews(this .getApplicationContext().getPackageName(), R.layout.widget_layout); Log.w("WidgetExample", String.valueOf(number)); // Set the text remoteViews.setTextViewText(R.id.update, "Random: " + String.valueOf(number)); // Register an onClickListener Intent clickIntent = new Intent(this.getApplicationContext(), MyWidgetProvider.class); clickIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds); PendingIntent pendingIntent = PendingIntent.getBroadcast( getApplicationContext(), 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.update, pendingIntent); appWidgetManager.updateAppWidget(widgetId, remoteViews); } stopSelf(); // super.onStart(intent, startId); }