本文整理汇总了Java中android.content.Intent.putExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.putExtra方法的具体用法?Java Intent.putExtra怎么用?Java Intent.putExtra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.putExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createShortCut
import android.content.Intent; //导入方法依赖的package包/类
private boolean createShortCut() {
Intent intent = getIntent();
if (intent != null) {
if (intent.getAction() != null) {
if (intent.getAction().equals(Intent.ACTION_CREATE_SHORTCUT)) {
Intent result = new Intent(this, ShortCutActivity.class);
result.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_shortcut));
result.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this, ShortCutActivity.class));
setResult(RESULT_OK, result);
return true;
}
}
}
return false;
}
示例2: onOptionsItemSelected
import android.content.Intent; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
try {
switch (item.getItemId()) {
case R.id.howToItem:
Common.previousActivity = SettingsActivity.class;
Intent howToIntent = new Intent(this, WebViewActivity.class);
howToIntent.putExtra("activity_title", getString(R.string.how_to_item));
howToIntent.putExtra("web_url", getString(R.string.how_to_link));
startActivity(howToIntent);
break;
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
break;
}
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
示例3: setUp
import android.content.Intent; //导入方法依赖的package包/类
public void setUp() throws Exception{
Log.e("TestScript_Guide", "setUp test!!");
setActivityInitialTouchMode(false);
weappApplication = new WeappJsBaseTestCase();
mInstrumentation = getInstrumentation();
Intent intent = new Intent();
intent.putExtra("bundleUrl", Constants.BUNDLE_URL);
launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent);
waTestPageActivity = getActivity();
// waTestPageActivity.getIntent().getData().toString();
Log.e(TAG,"activity1=" + waTestPageActivity.toString() );
Thread.sleep(3000);
mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container);
setViewGroup(mViewGroup);
addAllTargetView("TC_");
sleep(1000);
}
示例4: notifyPause
import android.content.Intent; //导入方法依赖的package包/类
public static void notifyPause(Context mContext, DownloadInfo info) {
if (callbackCategory == DataCallbackCategory.BROADCAST) {
Intent notifyIntent = baseIntent(mContext, info);
notifyIntent.putExtra("type", 3);
mContext.sendBroadcast(notifyIntent);
return;
}
callbackClient(3, info);
}
示例5: examineArtwork
import android.content.Intent; //导入方法依赖的package包/类
private void examineArtwork(String beaconMacAddr) {
try {
Artwork art = ArtworkData.getArtwork(beaconMacAddr);
Intent intent = new Intent(getContext(), ScrollingActivity.class);
intent.putExtra(ARTWORK_MESSAGE_NAME, art.getName());
intent.putExtra(ARTWORK_MESSAGE_TEXT, art.getTextSrc());
intent.putExtra(ARTWORK_MESSAGE_IMAGE, art.getImageSrc());
/*Activity activity = getActivity();
if (activity.getClass().equals(MainActivity.class)) {
((MainActivity) activity).stopScan();
}*/
startActivity(intent);
} catch (ArtworkNotFoundException ae) {
}
}
示例6: onSuccess
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onSuccess(int position, String name, String description) {
AppToast.showToast("分组修改成功");
Intent data = new Intent();
data.putExtra(INTENT_POSITION, position);
data.putExtra(INTENT_NAME, name);
data.putExtra(INTENT_DESC, description);
setResult(RESULT_OK, data);
finish();
}
示例7: setup
import android.content.Intent; //导入方法依赖的package包/类
@Before
public void setup() {
Utils.deleteExistingAccounts(preferences);
Account account = Preferences.getPreferences(shadowApplication.getApplicationContext()).newAccount();
account.setStoreUri("imap://PLAIN:test:password/1|@hotmail.com:143");
Intent intent = new Intent();
intent.putExtra("account", account.getUuid());
controller = Robolectric.buildActivity( AccountSettings.class ).withIntent(intent)
.create().resume();
}
示例8: launchRepWifiMainActivity
import android.content.Intent; //导入方法依赖的package包/类
private void launchRepWifiMainActivity(Context context, int reqCode) {
Intent intent = new Intent(context, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
if (reqCode >= 0) {
intent.putExtra(ActivityLauncher.EXTRA_REQCODE, reqCode);
}
context.startActivity(intent);
}
示例9: saveNote
import android.content.Intent; //导入方法依赖的package包/类
private void saveNote() {
title = ((EditText) findViewById(R.id.note_title)).getText().toString();
note = ((EditText) findViewById(R.id.new_note)).getText().toString();
if (!note.isEmpty()) {
Intent data = new Intent(this, MainActivity.class);
data.putExtra("TITLE", title);
data.putExtra("NOTE", note);
setResult(Activity.RESULT_OK, data);
finish();
} else {
Snackbar.make(findViewById(R.id.add_note_layout), "You need to enter something to save it", Snackbar.LENGTH_LONG).show();
}
}
示例10: launchLitePlayerDefault
import android.content.Intent; //导入方法依赖的package包/类
public static void launchLitePlayerDefault(Context context, Intent mIntent) {
Intent liteIntent = context.getPackageManager().getLaunchIntentForPackage("com.letv.android.lite");
LogInfo.log("plugin", "intent is null?" + (liteIntent == null));
if (liteIntent != null && mIntent != null) {
LogInfo.log("sguotao", "launchMode:" + mIntent.getIntExtra("launchMode", 0));
LogInfo.log("sguotao", "from:" + mIntent.getStringExtra("packageName"));
LogInfo.log("sguotao", "pcode:" + mIntent.getStringExtra("pcode"));
LogInfo.log("sguotao", "vid:" + mIntent.getIntExtra("vid", 0));
LogInfo.log("sguotao", "jsonData:" + mIntent.getStringExtra("jsonData"));
liteIntent.putExtra("launchMode", mIntent.getIntExtra("launchMode", 0));
liteIntent.putExtra("pcode", mIntent.getStringExtra("pcode"));
liteIntent.putExtra("packageName", mIntent.getStringExtra("packageName"));
liteIntent.putExtra("vid", mIntent.getIntExtra("vid", 0));
liteIntent.putExtra("jsonData", mIntent.getStringExtra("jsonData"));
liteIntent.addFlags(536870912);
liteIntent.addFlags(268435456);
liteIntent.addFlags(67108864);
try {
context.startActivity(liteIntent);
} catch (Exception e) {
LogInfo.log("zhuqiao", "launchLitePlayerDefault error:" + e.getMessage());
ApkManager.getInstance().setPluginInstallState("com.letv.android.lite", PackageManagerCompat.INSTALL_FAILED_INTERNAL_ERROR);
System.exit(0);
}
ActivityUtils.getInstance().removeAll();
}
}
示例11: sendBroadcast
import android.content.Intent; //导入方法依赖的package包/类
/**
* 发送参数为 String 的数据广播
*
* @param action
* @param s
*/
public void sendBroadcast(String action, String s) {
Intent intent = new Intent();
intent.setAction(action);
intent.putExtra("String", s);
mContext.sendBroadcast(intent);
}
示例12: sendCompletedBroadcast
import android.content.Intent; //导入方法依赖的package包/类
public static void sendCompletedBroadcast(FileDownloadModel model) {
if (model == null) throw new IllegalArgumentException();
if (model.getStatus() != FileDownloadStatus.completed) throw new IllegalStateException();
final Intent intent = new Intent(ACTION_COMPLETED);
intent.putExtra(KEY_MODEL, model);
FileDownloadHelper.getAppContext().sendBroadcast(intent);
}
示例13: onClick
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
int position = getAdapterPosition();
if (position < 0 || position > mCategories.size()) return;
Intent intent = new Intent(mContext, WallpaperBoardBrowserActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(Extras.EXTRA_FRAGMENT_ID, Extras.ID_CATEGORY_WALLPAPERS);
intent.putExtra(Extras.EXTRA_CATEGORY, mCategories.get(position).getName());
intent.putExtra(Extras.EXTRA_COUNT, mCategories.get(position).getCount());
mContext.startActivity(intent);
}
示例14: setup
import android.content.Intent; //导入方法依赖的package包/类
@BeforeClass
public static void setup() throws IOException, TimeoutException {
server = new MockWebServer();
server.start();
serverUrl = server.url("").toString();
Intent s = new Intent(InstrumentationRegistry.getTargetContext(),
MediaApiService.class);
s.putExtra(MediaApiService.RECORDING_URL,serverUrl);
s.putExtra(MediaApiService.STREAMING_URL,serverUrl);
IBinder binder = mServiceRule.bindService(s);
service = ((MediaApiService.LocalBinder) binder).getService();
}
示例15: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)) {
MBApp application = MBApp.getApp();
Intent charChangedIntent = new Intent(application, IPCService.class);
charChangedIntent.putExtra(IPCConstants.INTENT_TYPE, EventCategories.IPC_BLE_NOTIFICATION_CHARACTERISTIC_CHANGED);
charChangedIntent.putExtra(IPCConstants.INTENT_CHARACTERISTIC_MESSAGE, Utils.makeMicroBitValue
(EventCategories.SAMSUNG_DEVICE_INFO_ID, EventSubCodes.SAMSUNG_INCOMING_SMS));
application.startService(charChangedIntent);
}
}