List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:Main.java
public static String getButtonText(Intent intent) { return intent.getStringExtra("button_text"); }
From source file:Main.java
/** * Gets the type.//from ww w .j av a 2s . c om * * @param intent * the intent * * @return the type */ public static String getType(Intent intent) { return intent.getStringExtra(TYPE_KEY); }
From source file:Main.java
/** * Gets the username.//w ww. j av a 2 s . c om * * @param intent * the intent * * @return the username */ public static String getUsername(Intent intent) { return intent.getStringExtra(USERNAME_KEY); }
From source file:Main.java
/** * Gets the uri./*w ww. ja v a 2s .c om*/ * * @param intent * the intent * * @return the uri */ public static String getUri(Intent intent) { return intent.getStringExtra(GAME_URI_KEY); }
From source file:Main.java
/** * Just like {@link Intent#getStringExtra(String)} but doesn't throw exceptions. *///from ww w . java 2 s . c om public static String safeGetStringExtra(Intent intent, String name) { try { return intent.getStringExtra(name); } catch (Throwable t) { // Catches un-parceling exceptions. Log.e(TAG, "getStringExtra failed on intent: " + intent); return null; } }
From source file:Main.java
public static String getReplaceKey(Intent intent) { if (intent == null) { return null; }// www. j a v a 2 s . c o m return intent.getStringExtra(KEY); }
From source file:edu.stanford.mobisocial.dungbeetle.model.AppState.java
@Deprecated public static AppState fromIntent(Intent intent) { String arg = intent.getStringExtra(EXTRA_APPLICATION_ARGUMENT); String pkg = intent.getStringExtra(EXTRA_APPLICATION_PACKAGE); String state = intent.getStringExtra(EXTRA_APPLICATION_STATE); String thumbImg = intent.getStringExtra(EXTRA_APPLICATION_IMG); String thumbText = intent.getStringExtra(EXTRA_APPLICATION_TEXT); Uri feedUri = (Uri) intent.getParcelableExtra(EXTRA_FEED_URI); return new AppState(pkg, arg, state, thumbImg, thumbText, feedUri.getLastPathSegment(), null); }
From source file:Main.java
public static String getStringExtra(Intent intent, String name) { if (!hasIntent(intent) || !hasExtra(intent, name)) return null; return intent.getStringExtra(name); }
From source file:Main.java
/** * Read the PDUs out of an SMS_RECEIVED_ACTION or a * DATA_SMS_RECEIVED_ACTION intent./*from ww w .j ava 2s .co m*/ * * @param intent the intent to read from * @return an array of SmsMessages for the PDUs */ public static SmsMessage[] getMessagesFromIntent(Intent intent) { Object[] messages = (Object[]) intent.getSerializableExtra("pdus"); String format = intent.getStringExtra("format"); int pduCount = messages.length; SmsMessage[] msgs = new SmsMessage[pduCount]; for (int i = 0; i < pduCount; i++) { byte[] pdu = (byte[]) messages[i]; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { msgs[i] = SmsMessage.createFromPdu(pdu, format); } else { msgs[i] = SmsMessage.createFromPdu(pdu); } } return msgs; }
From source file:Main.java
/** * Get string from extra or from metadata. * /*from ww w.j ava2s .c o m*/ * @param context * @param packagename * @param intent * @param extra * @param metadata * @return */ public static String getStringExtraOrMetadata(final Context context, final String packagename, final Intent intent, final String extra, final String metadata) { if (intent.hasExtra(extra) && intent.getStringExtra(extra) != null) { return intent.getStringExtra(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 && !TextUtils.isEmpty(md.getString(metadata))) { return md.getString(metadata); } else { return ""; } } }