List of usage examples for android.content Intent FLAG_ACTIVITY_FORWARD_RESULT
int FLAG_ACTIVITY_FORWARD_RESULT
To view the source code for android.content Intent FLAG_ACTIVITY_FORWARD_RESULT.
Click Source Link
From source file:com.nbplus.vbroadlauncher.HomeLauncherActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boolean isTablet = DisplayUtils.isTabletDevice(this); LauncherSettings.getInstance(this).setIsSmartPhone(!isTablet); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); setContentView(R.layout.activity_home_launcher); DeviceUtils.showDeviceInformation(); Log.d(TAG, ">>>DisplayUtils.getScreenDensity(this) = " + DisplayUtils.getScreenDensity(this)); // vitamio library load if (!LibsChecker.checkVitamioLibs(this)) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() { @Override//from w ww . ja va 2s . c om public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); alert.setMessage(R.string.alert_media_message); alert.show(); return; } mCurrentLocale = getResources().getConfiguration().locale; if (BuildConfig.DEBUG) { Point p = DisplayUtils.getScreenSize(this); Log.d(TAG, "Screen size px = " + p.x + ", py = " + p.y); Point screen = p; p = DisplayUtils.getScreenDp(this); Log.d(TAG, "Screen dp x = " + p.x + ", y = " + p.y); int density = DisplayUtils.getScreenDensity(this); Log.d(TAG, "Screen density = " + density); } if (isTablet) { //is tablet Log.d(TAG, "Tablet"); } else { //is phone Log.d(TAG, "isTabletDevice() returns Phone.. now check display inches"); double diagonalInches = DisplayUtils.getDisplayInches(this); if (diagonalInches >= 6.4) { // 800x400 ? portrait ? 6.43 ? . // 6.5inch device or bigger Log.d(TAG, "DisplayUtils.getDisplayInches() bigger than 6.5"); } else { if (!Constants.OPEN_BETA_PHONE) { // smaller device Log.d(TAG, "DisplayUtils.getDisplayInches() smaller than 6.5"); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); alert.setMessage(R.string.alert_phone_message); alert.show(); return; } } } if (!Constants.OPEN_BETA_PHONE || !LauncherSettings.getInstance(this).isSmartPhone()) { if (isMyLauncherDefault()) { Log.d(TAG, "isMyLauncherDefault() == true"); // fake home key event. Intent fakeIntent = new Intent(); fakeIntent.setAction(Intent.ACTION_MAIN); fakeIntent.addCategory(Intent.CATEGORY_HOME); fakeIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); startActivity(fakeIntent); } else { Log.d(TAG, "Constants.OPEN_BETA_PHONE == false || isMyLauncherDefault() == false"); //resetPreferredLauncherAndOpenChooser(); } } // ? .. ? ? ?. // ? ?. IntentFilter filter = new IntentFilter(); filter.addAction(Constants.ACTION_LAUNCHER_ACTIVITY_RUNNING); filter.addAction(IoTConstants.ACTION_RECEIVE_EMERGENCY_CALL_DEVICE_BROADCAST); LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, filter); Intent intent = new Intent(Constants.ACTION_LAUNCHER_ACTIVITY_RUNNING); mActivityRunningTime = System.currentTimeMillis(); intent.putExtra(Constants.EXTRA_LAUNCHER_ACTIVITY_RUNNING, mActivityRunningTime); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); // set background image setContentViewByOrientation(); if (LauncherSettings.getInstance(this).getPreferredUserLocation() == null) { Location defaultLocation = new Location("stub"); defaultLocation.setLongitude(126.929810); defaultLocation.setLatitude(37.488201); LauncherSettings.getInstance(this).setPreferredUserLocation(defaultLocation); } // First we need to check availability of play services mResultReceiver = new AddressResultReceiver(mActivityHandler); // Set defaults, then update using values stored in the Bundle. mAddressRequested = false; mAddressOutput = null; // Update values using data stored in the Bundle. updateValuesFromBundle(savedInstanceState); /** * ? ??? ? . * ?? ? . */ mBroadcastFramelayout = (FrameLayout) findViewById(R.id.realtimeBroadcastFragment); if (mBroadcastFramelayout != null) { mBroadcastFramelayout.setVisibility(View.GONE); } FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Bundle bundle; // check installation or bind to service VBroadcastServer serverInfo = LauncherSettings.getInstance(this).getServerInformation(); if (serverInfo == null || !Constants.VBROAD_INITIAL_PAGE.equals(serverInfo.getInitialServerPage())) { // ? ?. // ? Registration ? . LauncherSettings.getInstance(this).setServerInformation(null); LauncherSettings.getInstance(this).setIsCompletedSetup(false); // open user register fragment RegisterFragment registerFragment = new RegisterFragment(); bundle = new Bundle(); registerFragment.setArguments(bundle); fragmentTransaction.replace(R.id.launcherFragment, registerFragment); } else { if (LauncherSettings.getInstance(this).isCompletedSetup() == false) { LauncherSettings.getInstance(this).setServerInformation(null); // open user register fragment RegisterFragment registerFragment = new RegisterFragment(); bundle = new Bundle(); registerFragment.setArguments(bundle); fragmentTransaction.replace(R.id.launcherFragment, registerFragment); } else { // open main launcher fragment LauncherFragment launcherFragment = new LauncherFragment(); bundle = new Bundle(); launcherFragment.setArguments(bundle); fragmentTransaction.replace(R.id.launcherFragment, launcherFragment); } } fragmentTransaction.commit(); // initialize iot interface. String collectServerAddress = null; if (serverInfo != null) { String apiServer = serverInfo.getApiServer(); if (StringUtils.isEmptyString(apiServer)) { collectServerAddress = null; } else { collectServerAddress = apiServer + Constants.API_COLLECTED_IOT_DATA_CONTEXT; } } IoTResultCodes resCode = IoTInterface.getInstance().initialize(this, LauncherSettings.getInstance(this).getDeviceID(), collectServerAddress); if (!resCode.equals(IoTResultCodes.SUCCESS)) { if (resCode.equals(IoTResultCodes.BIND_SERVICE_FAILED)) { Toast.makeText(getApplicationContext(), "Bind IoT Service failed!!!", Toast.LENGTH_SHORT).show(); } } }
From source file:de.k3b.android.toGoZip.SettingsActivity.java
private boolean onCmdSend(CharSequence title) { ZipStorage storage = SettingsImpl.getCurrentZipStorage(this); Intent intent = new Intent(Intent.ACTION_SEND); Uri contentUri = Uri.parse(storage.getFullZipUriOrNull()); String mime = "application/zip"; intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); // EXTRA_CC, EXTRA_BCC // intent.putExtra(Intent.EXTRA_EMAIL, new String[]{toAddress}); intent.putExtra(Intent.EXTRA_SUBJECT, SettingsImpl.getZipFile()); // intent.putExtra(Intent.EXTRA_TEXT, body); intent.putExtra(Intent.EXTRA_STREAM, contentUri); intent.setType(mime);//from w ww. ja va 2 s . com final String debugMessage = "SettingsActivity.onCmdSend(" + title + ", startActivity='" + intent.toUri(0) + "')"; try { final Intent chooser = Intent.createChooser(intent, title); chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); this.startActivity(chooser); if (Global.debugEnabled) { Log.d(Global.LOG_CONTEXT, debugMessage); } } catch (Exception ex) { Log.w(Global.LOG_CONTEXT, debugMessage, ex); } return true; }
From source file:com.silentcircle.contacts.activities.ScContactSelectionActivity.java
public void startActivityAndForwardResult(final Intent intent) { intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); // Forward extras to the new activity Bundle extras = getIntent().getExtras(); if (extras != null) { intent.putExtras(extras);/* ww w . j a v a 2 s. c o m*/ } startActivity(intent); finish(); }
From source file:com.android.contacts.activities.ContactSelectionActivity.java
public void startActivityAndForwardResult(final Intent intent) { intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); // Forward extras to the new activity Bundle extras = getIntent().getExtras(); if (extras != null) { intent.putExtras(extras);//from w ww . ja v a 2s .co m } try { ImplicitIntentsUtil.startActivityInApp(ContactSelectionActivity.this, intent); } catch (ActivityNotFoundException e) { Log.e(TAG, "startActivity() failed: " + e); Toast.makeText(ContactSelectionActivity.this, R.string.missing_app, Toast.LENGTH_SHORT).show(); } finish(); }
From source file:com.android.packageinstaller.PackageInstallerActivity.java
private void startInstall() { // Start subactivity to actually install the application Intent newIntent = new Intent(); newIntent.putExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO, mPkgInfo.applicationInfo); newIntent.setData(mPackageURI);/* w w w.j a v a 2 s .c o m*/ newIntent.setClass(this, InstallAppProgress.class); String installerPackageName = getIntent().getStringExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME); if (mOriginatingURI != null) { newIntent.putExtra(Intent.EXTRA_ORIGINATING_URI, mOriginatingURI); } if (mReferrerURI != null) { newIntent.putExtra(Intent.EXTRA_REFERRER, mReferrerURI); } if (mOriginatingUid != VerificationParams.NO_UID) { newIntent.putExtra(Intent.EXTRA_ORIGINATING_UID, mOriginatingUid); } if (installerPackageName != null) { newIntent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, installerPackageName); } if (getIntent().getBooleanExtra(Intent.EXTRA_RETURN_RESULT, false)) { newIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true); newIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); } if (localLOGV) Log.i(TAG, "downloaded app uri=" + mPackageURI); startActivity(newIntent); finish(); }
From source file:com.android.documentsui.DocumentsActivity.java
public void onAppPicked(ResolveInfo info) { final Intent intent = new Intent(getIntent()); intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT); intent.setComponent(//from www. ja v a 2s.c o m new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name)); startActivityForResult(intent, CODE_FORWARD); }
From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java
public void onAppPicked(ResolveInfo info) { final Intent intent = new Intent(virtualIntent); intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT); intent.setComponent(// w ww . j a v a2s . c o m new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name)); startActivityForResult(intent, CODE_FORWARD); }
From source file:org.openintents.notepad.NoteEditor.java
private void importNote() { // Load the file into a new note. mFileContent = mText.getText().toString(); Uri newUri;//from w w w . j a v a2s . co m // Let's check whether the exactly same note already exists or not: Cursor c = getContentResolver().query(Notes.CONTENT_URI, new String[] { Notes._ID }, Notes.NOTE + " = ?", new String[] { mFileContent }, null); if (c != null && c.moveToFirst()) { // Same note exists already: long id = c.getLong(0); newUri = ContentUris.withAppendedId(Notes.CONTENT_URI, id); } else { // Add new note // Requested to insert: set that state, and create a new entry // in the container. // mState = STATE_INSERT; ContentValues values = new ContentValues(); values.put(Notes.NOTE, mFileContent); values.put(Notes.THEME, mTheme); newUri = getContentResolver().insert(Notes.CONTENT_URI, values); // If we were unable to create a new note, then just finish // this activity. A RESULT_CANCELED will be sent back to the // original activity if they requested a result. if (newUri == null) { Log.e(TAG, "Failed to insert new note."); finish(); return; } // The new entry was created, so assume all will end well and // set the result to be returned. // setResult(RESULT_OK, (new Intent()).setAction(mUri.toString())); // setResult(RESULT_OK, intent); } // Start a new editor: Intent intent = new Intent(); intent.setAction(Intent.ACTION_EDIT); intent.setData(newUri); intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); setIntent(intent); startActivity(intent); // and finish this editor finish(); }