Java Code Examples for android.content.Intent.putExtra()

The following are Jave code examples for showing how to use putExtra() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: KeyBlocker   File: ShortCutActivity.java   View Source Code Vote up 7 votes
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;
}
 
Example 2
Project: Swift-Braille-Soft-keyboard   File: SettingsActivity.java   View Source Code Vote up 7 votes
@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;
}
 
Example 3
Project: weex-3d-map   File: WeexUiTestCaseTcColorType.java   View Source Code Vote up 7 votes
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);


    }
 
Example 4
Project: letv   File: NotifyManage.java   View Source Code Vote up 7 votes
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);
}
 
Example 5
Project: AndroidMuseumBleManager   File: ScanFragment.java   View Source Code Vote up 6 votes
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) {
    }
}
 
Example 6
Project: Simpler   File: GroupEditActivity.java   View Source Code Vote up 6 votes
@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();
}
 
Example 7
Project: q-mail   File: AccountSettingsTest.java   View Source Code Vote up 6 votes
@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();
}
 
Example 8
Project: RepWifiApp   File: RepWifiIntentReceiver.java   View Source Code Vote up 6 votes
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);

    }
 
Example 9
Project: social-journal   File: AddNote.java   View Source Code Vote up 6 votes
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();
    }
}
 
Example 10
Project: letv   File: JarLaunchUtils.java   View Source Code Vote up 6 votes
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();
    }
}
 
Example 11
Project: LQRWeChat-master   File: BroadcastManager.java   View Source Code Vote up 6 votes
/**
 * 发送参数为 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);
}
 
Example 12
Project: GitHub   File: FileDownloadBroadcastHandler.java   View Source Code Vote up 6 votes
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);
}
 
Example 13
Project: wallpaperboard   File: WallpaperDetailsCategoryAdapter.java   View Source Code Vote up 6 votes
@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);
}
 
Example 14
Project: chaosflix-leanback   File: MediaApiServiceTest.java   View Source Code Vote up 6 votes
@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();
}
 
Example 15
Project: microbit   File: IncomingSMSPresenter.java   View Source Code Vote up 6 votes
@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);
    }
}
 
Example 16
Project: ActivityBuilder   File: RefManager.java   View Source Code Vote up 6 votes
/**
 * 用于 setResult 的 Intent
 */
public @NonNull Map<String, Object> getOrCreateRefMap(Intent intent) {
  Map<String, Object> refMap = getRefMap(intent);
  if (refMap == null) {
    refMap = new HashMap<>();
    int keyOfMap = intent.hashCode();
    intent.putExtra(KEY_OF_MAP, keyOfMap);
    sGlobalRefMap.put(keyOfMap, refMap);
  }
  return refMap;
}
 
Example 17
Project: orgzly-android   File: ReminderService.java   View Source Code Vote up 5 votes
/**
 * Notify reminder service about changes that might affect scheduling of reminders.
 */
public static void notifyDataChanged(Context context) {
    Intent intent = new Intent(context, ReminderService.class);
    intent.putExtra(ReminderService.EXTRA_EVENT, ReminderService.EVENT_DATA_CHANGED);
    context.startService(intent);
}
 
Example 18
Project: thesis-project   File: MainActivity2.java   View Source Code Vote up 5 votes
@Override
public void viewProfile(final Teacher teacher) {
    final Intent intent = new Intent(this, TeacherViewActivity.class);
    intent.putExtra("teacherId", teacher.getId());
    startActivity(intent);
}
 
Example 19
Project: youkes_browser   File: BrowserActivity.java   View Source Code Vote up 5 votes
@Override
public void showFileChooser(ValueCallback<Uri[]> filePathCallback) {
	if (mFilePathCallback != null) {
		mFilePathCallback.onReceiveValue(null);
	}
	mFilePathCallback = filePathCallback;

	Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
	if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
		// Create the File where the photo should go
		File photoFile = null;
		try {
			photoFile = Utils.createImageFile();
			takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
		} catch (IOException ex) {
			// Error occurred while creating the File
			Log.e(Constants.TAG, "Unable to create Image File", ex);
		}

		// Continue only if the File was successfully created
		if (photoFile != null) {
			mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
			takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
		} else {
			takePictureIntent = null;
		}
	}

	Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
	contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
	contentSelectionIntent.setType("image/*");

	Intent[] intentArray;
	if (takePictureIntent != null) {
		intentArray = new Intent[] { takePictureIntent };
	} else {
		intentArray = new Intent[0];
	}

	Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
	chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
	chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
	chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

	mActivity.startActivityForResult(chooserIntent, 1);
}
 
Example 20
Project: letv   File: ServiceInterface.java   View Source Code Vote up 5 votes
public static void a(Context context, String str, String str2, b bVar) {
    if (!e(context)) {
        if (!(context instanceof Application)) {
            context = context.getApplicationContext();
        }
        if (e.a(context)) {
            boolean z;
            String B = a.B();
            String C = a.C();
            if (str2 == null && str == null) {
                z.e(z[7], z[21]);
                z = false;
            } else {
                int i;
                boolean z2;
                if (str2 != null && str != null) {
                    i = 1;
                    z2 = ((B == null || str.equals(B)) && (C == null || str2.equals(C))) ? false : true;
                } else if (str == null) {
                    i = 2;
                    z2 = (C == null || str2.equals(C)) ? false : true;
                } else {
                    i = 3;
                    z2 = (B == null || str.equals(B)) ? false : true;
                }
                long D = a.D();
                long E = a.E();
                long currentTimeMillis = System.currentTimeMillis();
                z = (z2 || ((i != 3 || currentTimeMillis - D < com.umeng.analytics.a.h) && ((i != 2 || currentTimeMillis - E < com.umeng.analytics.a.h) && (i != 1 || (currentTimeMillis - D < com.umeng.analytics.a.h && currentTimeMillis - E < com.umeng.analytics.a.h))))) ? z2 : true;
                if (!z) {
                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(z[17]);
                    z.d(z[7], new StringBuilder(z[18]).append(B).append(z[16]).append(str).append(z[23]).append(C).append(z[27]).append(str2).append(z[19]).append(simpleDateFormat.format(new Date(D))).append(z[15]).append(simpleDateFormat.format(new Date(E))).append(z[28]).append(simpleDateFormat.format(new Date(currentTimeMillis))).append(z[26]).append(z).toString());
                }
            }
            if (z) {
                long k = a.k();
                if (!(bVar == null || bVar.c == null)) {
                    TagAliasOperator.a().a(Long.valueOf(k), bVar);
                }
                new StringBuilder(z[25]).append(k);
                z.c();
                TagAliasOperator.a().a(context);
                Intent intent = new Intent(context, PushService.class);
                intent.setAction(z[29]);
                intent.putExtra(z[20], str);
                intent.putExtra(z[24], str2);
                intent.putExtra(z[14], k);
                context.startService(intent);
                return;
            }
            z.e(z[7], z[22]);
            if (bVar.c != null) {
                bVar.c.gotResult(0, bVar.a, bVar.b);
            }
        }
    }
}