List of usage examples for android.content Intent getStringArrayExtra
public String[] getStringArrayExtra(String name)
From source file:com.muzima.service.DataSyncService.java
@Override protected void onHandleIntent(Intent intent) { int syncType = intent.getIntExtra(DataSyncServiceConstants.SYNC_TYPE, -1); Intent broadcastIntent = new Intent(); String[] credentials = intent.getStringArrayExtra(DataSyncServiceConstants.CREDENTIALS); broadcastIntent.setAction(BroadcastListenerActivity.MESSAGE_SENT_ACTION); broadcastIntent.putExtra(DataSyncServiceConstants.SYNC_TYPE, syncType); switch (syncType) { case DataSyncServiceConstants.SYNC_FORMS: updateNotificationMsg("Downloading Forms Metadata"); if (authenticationSuccessful(credentials, broadcastIntent)) { int[] result = muzimaSyncService.downloadForms(); String msg = "Downloaded " + result[1] + " forms"; prepareBroadcastMsg(broadcastIntent, result, msg); saveFormsSyncTime(result);//from w w w . j a va 2 s . com } break; case DataSyncServiceConstants.SYNC_TEMPLATES: String[] formIds = intent.getStringArrayExtra(DataSyncServiceConstants.FORM_IDS); updateNotificationMsg("Downloading Forms Template for " + formIds.length + " forms"); if (authenticationSuccessful(credentials, broadcastIntent)) { int[] result = muzimaSyncService.downloadFormTemplates(formIds); String msg = "Downloaded " + result[1] + " form templates and " + result[2] + "concepts"; broadcastIntent.putExtra(DataSyncServiceConstants.DOWNLOAD_COUNT_SECONDARY, result[2]); prepareBroadcastMsg(broadcastIntent, result, msg); } break; case DataSyncServiceConstants.SYNC_COHORTS: updateNotificationMsg("Downloading Cohorts"); if (authenticationSuccessful(credentials, broadcastIntent)) { int[] result = muzimaSyncService.downloadCohorts(); String msg = "Downloaded " + result[1] + " new cohorts" + "; and deleted " + result[2] + " cohorts"; prepareBroadcastMsg(broadcastIntent, result, msg); saveCohortsSyncTime(result); consolidateAndSyncIndependentPatients(broadcastIntent); } break; case DataSyncServiceConstants.SYNC_PATIENTS_FULL_DATA: String[] cohortIds = intent.getStringArrayExtra(DataSyncServiceConstants.COHORT_IDS); updateNotificationMsg("Downloading Patients"); if (authenticationSuccessful(credentials, broadcastIntent)) { downloadPatients(broadcastIntent, cohortIds); downloadObservationsAndEncounters(broadcastIntent, cohortIds); } break; case DataSyncServiceConstants.SYNC_PATIENTS_ONLY: String[] cohortIdsToDownload = intent.getStringArrayExtra(DataSyncServiceConstants.COHORT_IDS); updateNotificationMsg("Downloading Patients"); if (authenticationSuccessful(credentials, broadcastIntent)) { downloadPatients(broadcastIntent, cohortIdsToDownload); } break; case DataSyncServiceConstants.SYNC_PATIENTS_DATA_ONLY: String[] savedCohortIds = intent.getStringArrayExtra(DataSyncServiceConstants.COHORT_IDS); updateNotificationMsg("Downloading Patients data"); if (authenticationSuccessful(credentials, broadcastIntent)) { downloadObservationsAndEncounters(broadcastIntent, savedCohortIds); } break; case DataSyncServiceConstants.SYNC_UPLOAD_FORMS: updateNotificationMsg("Uploading Forms"); if (authenticationSuccessful(credentials, broadcastIntent)) { int[] result = muzimaSyncService.uploadAllCompletedForms(); broadcastIntent.putExtra(DataSyncServiceConstants.SYNC_TYPE, DataSyncServiceConstants.SYNC_UPLOAD_FORMS); prepareBroadcastMsgForFormUpload(broadcastIntent, result, "Uploaded the forms Successfully"); } break; case DataSyncServiceConstants.DOWNLOAD_PATIENT_ONLY: String[] patientsToBeDownloaded = intent .getStringArrayExtra(DataSyncServiceConstants.PATIENT_UUID_FOR_DOWNLOAD); if (authenticationSuccessful(credentials, broadcastIntent)) { downloadPatientsWithObsAndEncounters(broadcastIntent, patientsToBeDownloaded); } case DataSyncServiceConstants.SYNC_NOTIFICATIONS: String receiverUUid = intent.getStringExtra(NotificationStatusConstants.RECEIVER_UUID); String[] downloadedCohortIds = intent.getStringArrayExtra(DataSyncServiceConstants.COHORT_IDS); updateNotificationMsg("Downloading Notifications for receiver " + receiverUUid); if (authenticationSuccessful(credentials, broadcastIntent)) { int[] result = muzimaSyncService.downloadNotifications(receiverUUid); String msg = "Downloaded " + result[1] + " notifications"; prepareBroadcastMsg(broadcastIntent, result, msg); LocalBroadcastManager.getInstance(this).sendBroadcast(broadcastIntent); downloadObservationsAndEncounters(broadcastIntent, downloadedCohortIds); } default: break; } LocalBroadcastManager.getInstance(this).sendBroadcast(broadcastIntent); }
From source file:com.amaze.filemanager.asynchronous.services.ExtractService.java
@Override public int onStartCommand(Intent intent, int flags, final int startId) { String file = intent.getStringExtra(KEY_PATH_ZIP); String extractPath = intent.getStringExtra(KEY_PATH_EXTRACT); String[] entries = intent.getStringArrayExtra(KEY_ENTRIES_ZIP); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); accentColor = ((AppConfig) getApplication()).getUtilsProvider().getColorPreference() .getCurrentUserColorPreferences(this, sharedPreferences).accent; Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); customSmallContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_small); customBigContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_big); Intent stopIntent = new Intent(TAG_BROADCAST_EXTRACT_CANCEL); PendingIntent stopPendingIntent = PendingIntent.getBroadcast(context, 1234, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action action = new NotificationCompat.Action(R.drawable.ic_zip_box_grey600_36dp, getString(R.string.stop_ftp), stopPendingIntent); mBuilder = new NotificationCompat.Builder(context, NotificationConstants.CHANNEL_NORMAL_ID); mBuilder.setContentIntent(pendingIntent).setSmallIcon(R.drawable.ic_zip_box_grey600_36dp) .setContentIntent(pendingIntent).setCustomContentView(customSmallContentViews) .setCustomBigContentView(customBigContentViews).setCustomHeadsUpContentView(customSmallContentViews) .setStyle(new NotificationCompat.DecoratedCustomViewStyle()).addAction(action).setOngoing(true) .setColor(accentColor);/* www . j a v a 2s. c o m*/ NotificationConstants.setMetadata(getApplicationContext(), mBuilder, NotificationConstants.TYPE_NORMAL); startForeground(NotificationConstants.EXTRACT_ID, mBuilder.build()); initNotificationViews(); long totalSize = getTotalSize(file); progressHandler.setSourceSize(1); progressHandler.setTotalSize(totalSize); progressHandler.setProgressListener((speed) -> publishResults(speed, false, false)); super.onStartCommand(intent, flags, startId); super.progressHalted(); new DoWork(this, progressHandler, file, extractPath, entries).execute(); return START_STICKY; }
From source file:eu.geekgasm.kintrol.DeviceControlActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_device_control); Intent intent = getIntent(); deviceInfo = new DeviceInfo(intent.getStringExtra(EXTRA_IP_ADDRESS), intent.getStringExtra(EXTRA_DEVICE_NAME), intent.getStringArrayExtra(EXTRA_DEVICE_VOLUMES)); handler = new Handler(); deviceNameView = (TextView) findViewById(R.id.device_name); volumeView = new AutoSizeText(this, R.id.volume); operationStateView = new AutoSizeText(this, R.id.operation_state); sourceView = new AutoSizeText(this, R.id.current_source); surroundModeView = new AutoSizeText(this, R.id.current_surround_mode); deviceNameView.setText(deviceInfo.deviceName); discreteVolumeValue = deviceInfo.getFirstDiscreteVolumeValue(); }
From source file:com.google.android.demos.jamendo.app.JamendoListActivity.java
/** {@inheritDoc} */ public Loader<Cursor> onCreateLoader(int loaderId, Bundle args) { Intent intent = getIntent(); Uri uri = intent.getData();/*www. j ava 2s . c o m*/ String selectionExtra = intent.getStringExtra(JamendoContract.EXTRA_SELECTION); QueryBuilder builder = new QueryBuilder(selectionExtra); builder.append(JamendoContract.PARAM_IMAGE_SIZE, getDimensionPixelSizeAsString(getImageSize())); String[] projection = getProjection(); String selection = builder.build(); String[] selectionArgs = intent.getStringArrayExtra(JamendoContract.EXTRA_SELECTION_ARGS); String sortOrder = intent.getStringExtra(JamendoContract.EXTRA_SORT_ORDER); return new CursorLoader(this, uri, projection, selection, selectionArgs, sortOrder); }
From source file:potboiler.client.PotsActivity.java
License:asdf
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { if (requestCode == SELECT_CAMERA) { try { String[] files = data.getStringArrayExtra("files"); if (files.length > 0) { // sendData(files[0]); }/*from ww w.j av a 2s . c o m*/ } catch (Exception e) { } } } }
From source file:org.akvo.flow.service.SurveyDownloadService.java
public void onHandleIntent(Intent intent) { if (StatusUtil.hasDataConnection(this)) { try {/*from www .ja va 2 s .c o m*/ databaseAdaptor = new SurveyDbAdapter(this); databaseAdaptor.open(); String[] surveyIds = intent != null ? intent.getStringArrayExtra(EXTRA_SURVEYS) : null; checkAndDownload(surveyIds); } catch (Exception e) { Log.e(TAG, e.getMessage()); PersistentUncaughtExceptionHandler.recordException(e); } finally { databaseAdaptor.close(); } } sendBroadcastNotification(); }
From source file:com.farmerbb.taskbar.receiver.ReceiveSettingsReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Ignore this broadcast if this is the free version if (BuildConfig.APPLICATION_ID.equals(BuildConfig.PAID_APPLICATION_ID)) { // Get pinned and blocked apps PinnedBlockedApps pba = PinnedBlockedApps.getInstance(context); pba.clear(context);//from w w w . ja v a 2 s.co m String[] pinnedAppsPackageNames = intent.getStringArrayExtra("pinned_apps_package_names"); String[] pinnedAppsComponentNames = intent.getStringArrayExtra("pinned_apps_component_names"); String[] pinnedAppsLabels = intent.getStringArrayExtra("pinned_apps_labels"); long[] pinnedAppsUserIds = intent.getLongArrayExtra("pinned_apps_user_ids"); UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); LauncherApps launcherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE); if (pinnedAppsPackageNames != null && pinnedAppsComponentNames != null && pinnedAppsLabels != null) for (int i = 0; i < pinnedAppsPackageNames.length; i++) { Intent throwaway = new Intent(); throwaway.setComponent(ComponentName.unflattenFromString(pinnedAppsComponentNames[i])); long userId; if (pinnedAppsUserIds != null) userId = pinnedAppsUserIds[i]; else userId = userManager.getSerialNumberForUser(Process.myUserHandle()); AppEntry newEntry = new AppEntry(pinnedAppsPackageNames[i], pinnedAppsComponentNames[i], pinnedAppsLabels[i], IconCache.getInstance(context).getIcon(context, context.getPackageManager(), launcherApps.resolveActivity(throwaway, userManager.getUserForSerialNumber(userId))), true); newEntry.setUserId(userId); pba.addPinnedApp(context, newEntry); } String[] blockedAppsPackageNames = intent.getStringArrayExtra("blocked_apps_package_names"); String[] blockedAppsComponentNames = intent.getStringArrayExtra("blocked_apps_component_names"); String[] blockedAppsLabels = intent.getStringArrayExtra("blocked_apps_labels"); if (blockedAppsPackageNames != null && blockedAppsComponentNames != null && blockedAppsLabels != null) for (int i = 0; i < blockedAppsPackageNames.length; i++) { pba.addBlockedApp(context, new AppEntry(blockedAppsPackageNames[i], blockedAppsComponentNames[i], blockedAppsLabels[i], null, false)); } // Get blacklist Blacklist blacklist = Blacklist.getInstance(context); blacklist.clear(context); String[] blacklistPackageNames = intent.getStringArrayExtra("blacklist_package_names"); String[] blacklistLabels = intent.getStringArrayExtra("blacklist_labels"); if (blacklistPackageNames != null && blacklistLabels != null) for (int i = 0; i < blacklistPackageNames.length; i++) { blacklist.addBlockedApp(context, new BlacklistEntry(blacklistPackageNames[i], blacklistLabels[i])); } // Get top apps TopApps topApps = TopApps.getInstance(context); topApps.clear(context); String[] topAppsPackageNames = intent.getStringArrayExtra("top_apps_package_names"); String[] topAppsLabels = intent.getStringArrayExtra("top_apps_labels"); if (topAppsPackageNames != null && topAppsLabels != null) for (int i = 0; i < topAppsPackageNames.length; i++) { topApps.addTopApp(context, new BlacklistEntry(topAppsPackageNames[i], topAppsLabels[i])); } // Get saved window sizes if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { SavedWindowSizes savedWindowSizes = SavedWindowSizes.getInstance(context); savedWindowSizes.clear(context); String[] savedWindowSizesComponentNames = intent .getStringArrayExtra("saved_window_sizes_component_names"); String[] savedWindowSizesWindowSizes = intent .getStringArrayExtra("saved_window_sizes_window_sizes"); if (savedWindowSizesComponentNames != null && savedWindowSizesWindowSizes != null) for (int i = 0; i < savedWindowSizesComponentNames.length; i++) { savedWindowSizes.setWindowSize(context, savedWindowSizesComponentNames[i], savedWindowSizesWindowSizes[i]); } } // Get shared preferences String contents = intent.getStringExtra("preferences"); if (contents.length() > 0) try { File file = new File(context.getFilesDir().getParent() + "/shared_prefs/" + BuildConfig.APPLICATION_ID + "_preferences.xml"); FileOutputStream output = new FileOutputStream(file); output.write(contents.getBytes()); output.close(); } catch (IOException e) { /* Gracefully fail */ } try { File file = new File(context.getFilesDir() + File.separator + "imported_successfully"); if (file.createNewFile()) LocalBroadcastManager.getInstance(context) .sendBroadcast(new Intent("com.farmerbb.taskbar.IMPORT_FINISHED")); } catch (IOException e) { /* Gracefully fail */ } } }
From source file:com.google.android.demos.jamendo.app.AlbumGalleryActivity.java
/** {@inheritDoc} */ public Loader<Cursor> onCreateLoader(int id, Bundle args) { Intent intent = getIntent(); Uri uri = Albums.CONTENT_URI; String selectionExtra = intent.getStringExtra(JamendoContract.EXTRA_SELECTION); QueryBuilder builder = new QueryBuilder(selectionExtra); builder.append(JamendoContract.PARAM_IMAGE_SIZE, String.valueOf(mImageSize)); String[] projection = AlbumGalleryAdapter.PROJECTION; String selection = builder.build(); String[] selectionArgs = intent.getStringArrayExtra(JamendoContract.EXTRA_SELECTION_ARGS); String sortOrder = intent.getStringExtra(JamendoContract.EXTRA_SORT_ORDER); return new CursorLoader(this, uri, projection, selection, selectionArgs, sortOrder); }
From source file:com.google.android.demos.jamendo.app.ArtistGalleryActivity.java
/** {@inheritDoc} */ public Loader<Cursor> onCreateLoader(int loaderId, Bundle args) { Intent intent = getIntent(); Uri uri = Artists.CONTENT_URI; String selectionExtra = intent.getStringExtra(JamendoContract.EXTRA_SELECTION); QueryBuilder builder = new QueryBuilder(selectionExtra); builder.append(JamendoContract.PARAM_IMAGE_SIZE, String.valueOf(mImageSize)); String[] projection = ArtistGalleryAdapter.PROJECTION; String selection = builder.build(); String[] selectionArgs = intent.getStringArrayExtra(JamendoContract.EXTRA_SELECTION_ARGS); String sortOrder = intent.getStringExtra(JamendoContract.EXTRA_SORT_ORDER); return new CursorLoader(this, uri, projection, selection, selectionArgs, sortOrder); }
From source file:com.zegoggles.smssync.activity.MainActivity.java
private void requestPermissionsIfNeeded() { final Intent intent = getIntent(); if (intent != null && intent.hasExtra(EXTRA_PERMISSIONS)) { final String[] permissions = intent.getStringArrayExtra(EXTRA_PERMISSIONS); Log.v(TAG, "requesting permissions " + Arrays.toString(permissions)); ActivityCompat.requestPermissions(this, permissions, REQUEST_PERMISSIONS_BACKUP_SERVICE); }//w w w. jav a2s . c om }