本文整理了Java中android.os.Bundle.putString()
方法的一些代码示例,展示了Bundle.putString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.putString()
方法的具体详情如下:
包路径:android.os.Bundle
类名称:Bundle
方法名:putString
暂无
代码示例来源:origin: stackoverflow.com
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
// Save UI state changes to the savedInstanceState.
// This bundle will be passed to onCreate if the process is
// killed and restarted.
savedInstanceState.putBoolean("MyBoolean", true);
savedInstanceState.putDouble("myDouble", 1.9);
savedInstanceState.putInt("MyInt", 1);
savedInstanceState.putString("MyString", "Welcome back to Android");
// etc.
}
代码示例来源:origin: pockethub/PocketHub
public static Bundle buildBundle(String name, String mail, String avatar) {
Bundle userData = new Bundle();
userData.putString(AccountsHelper.USER_PIC, avatar);
userData.putString(AccountsHelper.USER_MAIL, mail);
userData.putString(AccountsHelper.USER_NAME, name);
return userData;
}
代码示例来源:origin: stackoverflow.com
Intent mIntent = new Intent(this, Example.class);
Bundle mBundle = new Bundle();
mBundle.putString(key, value);
mIntent.putExtras(mBundle);
代码示例来源:origin: stackoverflow.com
public class SecondFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.second_frag, container, false);
TextView tv = (TextView) v.findViewById(R.id.tvFragSecond);
tv.setText(getArguments().getString("msg"));
return v;
}
public static SecondFragment newInstance(String text) {
SecondFragment f = new SecondFragment();
Bundle b = new Bundle();
b.putString("msg", text);
f.setArguments(b);
return f;
}
}
代码示例来源:origin: robolectric/robolectric
private Bundle getAuthToken(Account account, String authTokenType)
throws OperationCanceledException, IOException, AuthenticatorException {
Bundle result = new Bundle();
String authToken = blockingGetAuthToken(account, authTokenType, false);
result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
result.putString(AccountManager.KEY_AUTHTOKEN, authToken);
if (authToken != null) {
return result;
}
if (!authenticators.containsKey(account.type)) {
throw new AuthenticatorException("No authenticator specified for " + account.type);
}
Intent resultIntent = new Intent();
result.putParcelable(AccountManager.KEY_INTENT, resultIntent);
return result;
}
代码示例来源:origin: pockethub/PocketHub
/**
* Create bundle with standard arguments
*
* @param title
* @param message
* @param requestCode
* @return bundle
*/
protected static Bundle createArguments(final String title,
final String message, final int requestCode) {
Bundle arguments = new Bundle();
arguments.putInt(ARG_REQUEST_CODE, requestCode);
arguments.putString(ARG_TITLE, title);
arguments.putString(ARG_MESSAGE, message);
return arguments;
}
代码示例来源:origin: android-hacker/VirtualXposed
@Override
public void onResult(Bundle result) throws RemoteException {
if (result != null) {
String label = result.getString(AccountManager.KEY_AUTH_TOKEN_LABEL);
Bundle bundle = new Bundle();
bundle.putString(AccountManager.KEY_AUTH_TOKEN_LABEL, label);
super.onResult(bundle);
} else {
super.onResult(null);
}
}
}.bind();
代码示例来源:origin: stackoverflow.com
/* Start Activity */
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.thinoo.ActivityTest", "com.thinoo.ActivityTest.NewActivity");
startActivityForResult(intent,90);
}
/* Called when the second activity's finished */
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(requestCode) {
case 90:
if (resultCode == RESULT_OK) {
Bundle res = data.getExtras();
String result = res.getString("param_result");
Log.d("FIRST", "result:"+result);
}
break;
}
}
private void finishWithResult()
{
Bundle conData = new Bundle();
conData.putString("param_result", "Thanks Thanks");
Intent intent = new Intent();
intent.putExtras(conData);
setResult(RESULT_OK, intent);
finish();
}
代码示例来源:origin: stackoverflow.com
Intent mIntent = new Intent(this, Example.class);
Bundle extras = mIntent.getExtras();
extras.putString(key, value);
代码示例来源:origin: facebook/facebook-android-sdk
private static Bundle jsonToBundle(JSONObject jsonObject) throws JSONException {
Bundle bundle = new Bundle();
Iterator iter = jsonObject.keys();
while (iter.hasNext()) {
String key = (String) iter.next();
String value = jsonObject.getString(key);
bundle.putString(key,value);
}
return bundle;
}
代码示例来源:origin: stackoverflow.com
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_layout, container, false);
mTime = savedInstanceState.getString("time_key");
} else {
mTime = "" + Calendar.getInstance().getTimeInMillis();
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("time_key", mTime);
代码示例来源:origin: ankidroid/Anki-Android
@Override
public Message getDialogHandlerMessage() {
Message msg = Message.obtain();
msg.what = DialogHandler.MSG_SHOW_SYNC_ERROR_DIALOG;
Bundle b = new Bundle();
b.putInt("dialogType", getArguments().getInt("dialogType"));
b.putString("dialogMessage", getArguments().getString("dialogMessage"));
msg.setData(b);
return msg;
}
代码示例来源:origin: facebook/facebook-android-sdk
arrayList.add("third");
Bundle innerBundle1 = new Bundle();
innerBundle1.putInt("inner", 1);
Bundle innerBundle2 = new Bundle();
innerBundle2.putString("inner", "2");
innerBundle2.putStringArray("deep list", new String[] {"7", "8"});
Bundle b = new Bundle();
b.putBoolean("boolValue", true);
b.putInt("intValue", 7);
b.putLong("longValue", 5000000000l);
b.putDouble("doubleValue", 3.14);
b.putString("stringValue", "hello world");
b.putStringArray("stringArrayValue", new String[] {"first", "second"});
b.putStringArrayList("stringArrayListValue", arrayList);
assertEquals(5000000000l, json.getLong("longValue"));
assertEquals(3.14, json.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA);
assertEquals("hello world", json.getString("stringValue"));
assertEquals(1, innerJson.getInt("inner"));
innerJson = innerJson.getJSONObject("nested bundle");
assertEquals("2", innerJson.getString("inner"));
代码示例来源:origin: stackoverflow.com
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putString("message", "This is my message to be reloaded");
super.onSaveInstanceState(outState);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
String message = savedInstanceState.getString("message");
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
}
}
代码示例来源:origin: facebook/facebook-android-sdk
/**
* Logs an app event that tracks that the application was open via Push Notification.
* @param payload Notification payload received.
*/
public void logPushNotificationOpen(Bundle payload, String action) {
String campaignId = null;
try {
String payloadString = payload.getString(PUSH_PAYLOAD_KEY);
if (Utility.isNullOrEmpty(payloadString)) {
return; // Ignore the payload if no fb push payload is present.
}
JSONObject facebookPayload = new JSONObject(payloadString);
campaignId = facebookPayload.getString(PUSH_PAYLOAD_CAMPAIGN_KEY);
} catch (JSONException je) {
// ignore
}
if (campaignId == null) {
Logger.log(LoggingBehavior.DEVELOPER_ERRORS, TAG,
"Malformed payload specified for logging a push notification open.");
return;
}
Bundle parameters = new Bundle();
parameters.putString(APP_EVENT_PUSH_PARAMETER_CAMPAIGN, campaignId);
if (action != null) {
parameters.putString(APP_EVENT_PUSH_PARAMETER_ACTION, action);
}
logEvent(APP_EVENT_NAME_PUSH_OPENED, parameters);
}
代码示例来源:origin: googlesamples/easypermissions
Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putString(KEY_POSITIVE_BUTTON, positiveButton);
bundle.putString(KEY_NEGATIVE_BUTTON, negativeButton);
bundle.putString(KEY_RATIONALE_MESSAGE, rationaleMsg);
bundle.putInt(KEY_THEME, theme);
bundle.putInt(KEY_REQUEST_CODE, requestCode);
bundle.putStringArray(KEY_PERMISSIONS, permissions);
return bundle;
}
代码示例来源:origin: facebook/facebook-android-sdk
Bundle bridgeArguments = new Bundle();
bridgeArguments.putString(BRIDGE_ARG_ACTION_ID_STRING, callId);
Utility.putNonEmptyString(bridgeArguments, BRIDGE_ARG_APP_NAME_STRING, applicationName);
Bundle methodArguments = (params == null) ? new Bundle() : params;
intent.putExtra(EXTRA_PROTOCOL_METHOD_ARGS, methodArguments);
} else {
intent.putExtra(EXTRA_APPLICATION_NAME, applicationName);
intent.putExtras(params);
代码示例来源:origin: stackoverflow.com
Intent intent = new Intent(this, MyActivity.class);
Bundle extras = new Bundle();
extras.putString("EXTRA_USERNAME","my_username");
extras.putString("EXTRA_PASSWORD","my_password");
intent.putExtras(extras);
startActivity(intent);
代码示例来源:origin: stackoverflow.com
public class ThirdFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.third_frag, container, false);
TextView tv = (TextView) v.findViewById(R.id.tvFragThird);
tv.setText(getArguments().getString("msg"));
return v;
}
public static ThirdFragment newInstance(String text) {
ThirdFragment f = new ThirdFragment();
Bundle b = new Bundle();
b.putString("msg", text);
f.setArguments(b);
return f;
}
}
代码示例来源:origin: ankidroid/Anki-Android
public static Intent getPreferenceSubscreenIntent(Context context, String subscreen) {
Intent i = new Intent(context, Preferences.class);
i.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, "com.ichi2.anki.Preferences$SettingsFragment");
Bundle extras = new Bundle();
extras.putString("subscreen", subscreen);
i.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, extras);
i.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
return i;
}
内容来源于网络,如有侵权,请联系作者删除!