List of usage examples for android.content Intent getStringArrayExtra
public String[] getStringArrayExtra(String name)
From source file:Main.java
public static String[] getStringArrayExtra(Intent intent, String name) { if (!hasIntent(intent) || !hasExtra(intent, name)) return null; return intent.getStringArrayExtra(name); }
From source file:Main.java
/** * Get String array from Extra or from Meta-data through resources. * /*w ww.j a v a2s . co m*/ * @param packagename * @param intent * @param extra * @param metadata */ public static String[] getStringArrayExtraOrMetadata(final Context context, final String packagename, final Intent intent, final String extra, final String metadata) { if (intent.hasExtra(extra) && intent.getStringArrayExtra(extra) != null) { return intent.getStringArrayExtra(extra); } else { //Try meta data of package Bundle md = null; try { md = context.getPackageManager().getApplicationInfo(packagename, PackageManager.GET_META_DATA).metaData; } catch (NameNotFoundException e) { Log.e(TAG, "Package name not found", e); } if (md != null) { String[] array = null; try { int id = md.getInt(metadata); Resources resources = context.getPackageManager().getResourcesForApplication(packagename); array = resources.getStringArray(id); } catch (NameNotFoundException e) { Log.e(TAG, "Package name not found ", e); } catch (NumberFormatException e) { Log.e(TAG, "Metadata not valid id.", e); } catch (Resources.NotFoundException e) { Log.e(TAG, "Resource not found.", e); } if (array != null) { return array; } else { return null; } } else { return null; } } }
From source file:org.xwalk.core.xwview.shell.XWalkViewShellActivity.java
private static String[] getCommandLineParamsFromIntent(Intent intent) { return intent != null ? intent.getStringArrayExtra(COMMAND_LINE_ARGS_KEY) : null; }
From source file:com.kymjs.gallery.KJGalleryActivity.java
@Override public void initData() { super.initData(); Intent from = getIntent(); imageUrls = from.getStringArrayExtra(URL_KEY); index = from.getIntExtra(URL_INDEX, 0); }
From source file:com.ademsha.appnotifico.NotificationHubCommandReceiver.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void cancelNotifications(Intent intent) { String[] keys = intent.getStringArrayExtra("data"); if (keys.length > 0) { notificationHub.cancelNotifications(keys); }/*ww w .j a v a 2 s. co m*/ }
From source file:com.ademsha.appnotifico.NotificationHubCommandReceiver.java
private void getActiveNotifications(Context context, Intent intent) { String[] keys = intent.getStringArrayExtra("data"); if (keys.length > 0) { JSONArray notifications = new JSONArray(); for (StatusBarNotification statusBarNotification : notificationHub.getActiveNotifications(keys)) { notifications.put(NotificationDataHelper.getStatusBarNotificationDataAsJSON(statusBarNotification)); }//from w ww. ja v a2 s . c o m Intent dataIntent = new Intent(NotificationHubConfig.NOTIFICATION_HUB_DATA_RECIEVER_INTENT); dataIntent.putExtra("command", "get-all"); dataIntent.putExtra("data", " " + notifications.toString() + "\n"); context.getApplicationContext().sendBroadcast(dataIntent); } }
From source file:de.vanita5.twittnuker.activity.support.ActivityPickerActivity.java
@Override public Loader<List<ResolveInfo>> onCreateLoader(final int id, final Bundle args) { final Intent intent = getIntent(); final Intent extraIntent = intent.getParcelableExtra(EXTRA_INTENT); final String[] blacklist = intent.getStringArrayExtra(EXTRA_BLACKLIST); return new IntentActivitiesLoader(this, extraIntent, blacklist, 0); }
From source file:org.transdroid.gui.Details.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_details); getSupportActionBar().setDisplayShowTitleEnabled(true); if (savedInstanceState == null) { Intent i = getIntent(); // Get torrent and daemon form the new intent int daemonNumber = i.getIntExtra(STATE_DAEMON, 0); String[] existingLabels = i.getStringArrayExtra(STATE_LABELS); Torrent torrent = i.getParcelableExtra(STATE_TORRENT); // Start the fragment for this torrent FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.details, new DetailsFragment(null, daemonNumber, torrent, existingLabels)); if (getSupportFragmentManager().findFragmentById(R.id.details) != null) { ft.addToBackStack(null);/*from ww w . jav a 2 s . c o m*/ } ft.commit(); } }
From source file:com.adamhurwitz.android.popularmovies.service.YouTubeService.java
@Override protected void onHandleIntent(Intent intent) { String[] youTubeArray = intent.getStringArrayExtra("YOUTUBE_QUERY"); // These two need to be declared outside the try/catch // so that they can be closed in the finally block. HttpURLConnection urlConnection = null; BufferedReader reader = null; // Will contain the raw JSON response as a string. String jsonResponse = null;// w w w . j a v a 2s .com try { // Construct the URL to fetch data from and make the connection. Uri builtUri = Uri.parse(BASE_URL + youTubeArray[0] + VIDEOS).buildUpon() .appendQueryParameter(KEY_PARAMETER, KEY_CODE).build(); URL url = new URL(builtUri.toString()); urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestMethod("GET"); urlConnection.connect(); // See if the input stream is not null and a connection could be made. If it is null, do // not process any further. InputStream inputStream = urlConnection.getInputStream(); StringBuilder buffer = new StringBuilder(); if (inputStream == null) { return; } // Read the input stream to see if any valid response was give. reader = new BufferedReader(new InputStreamReader(inputStream)); String line; while ((line = reader.readLine()) != null) { // Add new to make debugging easier. buffer.append(line).append("\n"); } if (buffer.length() == 0) { // If the stream is empty, do not process any further. return; } jsonResponse = buffer.toString(); } catch (IOException e) { // If there was no valid Google doodle data returned, there is no point in attempting to // parse it. Log.e(LOG_TAG, "Error, IOException.", e); return; } finally { // Make sure to close the connection and the reader no matter what. if (urlConnection != null) { urlConnection.disconnect(); } if (reader != null) { try { reader.close(); } catch (final IOException e) { Log.e(LOG_TAG, "Error closing stream ", e); } } } // return ArrayList of MovieData Objects parseJSONResponse(jsonResponse, youTubeArray[1]); // Any other case that gets here is an error that was not caught, so return null. return; }
From source file:com.adamhurwitz.android.popularmovies.service.ReviewService.java
@Override protected void onHandleIntent(Intent intent) { String[] reviewArray = intent.getStringArrayExtra("REVIEW_QUERY"); // These two need to be declared outside the try/catch // so that they can be closed in the finally block. HttpURLConnection urlConnection = null; BufferedReader reader = null; // Will contain the raw JSON response as a string. String jsonResponse = null;// w w w . j av a2s. co m try { // Construct the URL to fetch data from and make the connection. Uri builtUri = Uri.parse(BASE_URL + reviewArray[0] + "/reviews").buildUpon() .appendQueryParameter(KEY_PARAMETER, KEY_CODE).build(); URL url = new URL(builtUri.toString()); urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestMethod("GET"); urlConnection.connect(); // See if the input stream is not null and a connection could be made. If it is null, do // not process any further. InputStream inputStream = urlConnection.getInputStream(); StringBuilder buffer = new StringBuilder(); if (inputStream == null) { return; } // Read the input stream to see if any valid response was give. reader = new BufferedReader(new InputStreamReader(inputStream)); String line; while ((line = reader.readLine()) != null) { // Add new to make debugging easier. buffer.append(line).append("\n"); } if (buffer.length() == 0) { // If the stream is empty, do not process any further. return; } jsonResponse = buffer.toString(); } catch (IOException e) { // If there was no valid Google doodle data returned, there is no point in attempting to // parse it. Log.e(LOG_TAG, "Error, IOException.", e); return; } finally { // Make sure to close the connection and the reader no matter what. if (urlConnection != null) { urlConnection.disconnect(); } if (reader != null) { try { reader.close(); } catch (final IOException e) { Log.e(LOG_TAG, "Error closing stream ", e); } } } try { parseJSONResponse(jsonResponse, reviewArray[1]); } catch (JSONException e) { Log.e(LOG_TAG, e.getMessage(), e); e.printStackTrace(); } // Any other case that gets here is an error that was not caught, so return null. return; }