List of usage examples for android.content Intent setFlags
public @NonNull Intent setFlags(@Flags int flags)
From source file:com.cleanwiz.applock.service.LockService.java
private void passwordLock(String pkgName) { AppLockApplication.getInstance().clearAllActivity(); Intent intent; if (SharedPreferenceUtil.readIsNumModel()) { intent = new Intent(this, NumberUnlockActivity.class); } else {//w w w .java 2 s .c o m intent = new Intent(this, GestureUnlockActivity.class); } intent.putExtra(MyConstants.LOCK_PACKAGE_NAME, pkgName); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
From source file:com.pvo.activity.MainFragmentActivity.java
@Override public void onBackPressed() { if (fragmentStack.size() > 1) { System.out.println("--> On back press if condition <---"); FragmentTransaction ft = fragmentManager.beginTransaction(); if (ft != null) { fragmentStack.lastElement().onPause(); ft.remove(fragmentStack.pop()); Fragment lastFragment = fragmentStack.lastElement(); lastFragment.onResume();/* w ww . ja v a 2s . co m*/ ft.show(lastFragment); ft.commit(); } } else { System.out.println("--> On back press else condition <---"); Fragment visible = getVisibleFragment(); if (visible instanceof ZNotificationMainFragment) { clearStoreData(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else { redirectToNotificaiton(); } } }
From source file:org.pixmob.appengine.client.AppEngineClient.java
private String getAuthToken() throws AppEngineAuthenticationException { // get an authentication token from the AccountManager: // this call is asynchronous, as the user may not respond immediately final AccountManagerFuture<Bundle> futureBundle = accountManager.getAuthToken(account, "ah", true, null, null);/*w w w . ja v a2 s . c o m*/ final Bundle authBundle; try { authBundle = futureBundle.getResult(); } catch (OperationCanceledException e) { throw new AppEngineAuthenticationException(AUTHENTICATION_UNAVAILABLE, e); } catch (AuthenticatorException e) { throw new AppEngineAuthenticationException(AUTHENTICATION_UNAVAILABLE, e); } catch (IOException e) { throw new AppEngineAuthenticationException(AUTHENTICATION_UNAVAILABLE, e); } final String authToken = authBundle.getString(AccountManager.KEY_AUTHTOKEN); if (authToken == null) { // no authentication token was given: the user should give its // permission through an item in the notification bar Log.i(TAG, "Authentication permission is required"); final Intent authPermIntent = (Intent) authBundle.get(AccountManager.KEY_INTENT); int flags = authPermIntent.getFlags(); flags &= ~Intent.FLAG_ACTIVITY_NEW_TASK; authPermIntent.setFlags(flags); throw new AppEngineAuthenticationException(AUTHENTICATION_PENDING, authPermIntent); } return authToken; }
From source file:com.github.barcodeeye.scan.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.activity_capture); context2 = this; StringBuilder loginData = new StringBuilder(); try {//from w ww . ja va 2 s. c om File f = new File(getCacheDir(), "LoginData.txt"); if (f.exists()) { BufferedReader br = new BufferedReader(new FileReader(f)); String line; while ((line = br.readLine()) != null) { loginData.append(line); } if (!loginData.toString().isEmpty()) { System.out.println("!!!!!!" + loginData.toString() + "!!!!!!!"); // Intent Creation and Initialization Intent intent = new Intent(context2, InformationPreviewActivity.class); //I have added the line: (flags) (for closing the first activity) intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Create a Bundle and Put Bundle into it (SENDS PERSON) Bundle bundleObject = new Bundle(); bundleObject.putSerializable("key", loginData.toString()); // Put Bundle into Intent and call start Activity intent.putExtras(bundleObject); startActivity(intent); //I have added the line: (finish) (for closing the first activity) finish(); } } } catch (IOException e) { //You'll need to add proper error handling here } mImageManager = new ImageManager(this); mHasSurface = false; mInactivityTimer = new InactivityTimer(this); mBeepManager = new BeepManager(this); mAmbientLightManager = new AmbientLightManager(this); mViewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); if (loginData.toString().isEmpty()) { Toast.makeText(getApplicationContext(), "Scan QR code for Login", Toast.LENGTH_LONG).show(); } PreferenceManager.setDefaultValues(this, R.xml.preferences, false); }
From source file:com.rainmakerlabs.bleepsample.BleepService.java
public void imgShow(Bitmap bitmap, String strImgMsg) { MainActivity.adlib.put(strImgMsg, bitmap); Log.d("Portal", "Added an image. Size is now " + MainActivity.adlib.size()); Log.i("Portal", "Image added for key " + strImgMsg); if (MainActivity.myGallery == null) return;//from w w w .j a v a2 s . c o m if (MainActivity.gal_size < MainActivity.adlib.size()) { //new image has been added and the layout is initialized LinearLayout superLL = (LinearLayout) MainActivity.myGallery.getParent().getParent(); if (MainActivity.gal_size < 1) { ImageView imgSplash = (ImageView) superLL.findViewById(R.id.imgSplash); imgSplash.setVisibility(View.INVISIBLE); } LinearLayout layout = new LinearLayout(getApplicationContext()); layout.setOrientation(LinearLayout.VERTICAL); layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); layout.setGravity(Gravity.CENTER); ImageView imageview = new ImageView(getApplicationContext()); imageview.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1000)); imageview.setScaleType(ImageView.ScaleType.CENTER_CROP); imageview.setImageBitmap(bitmap); //Add a button to go with it Button btnBuy = new Button(getApplicationContext()); LinearLayout.LayoutParams btnParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); btnParams.setMargins(-10, -10, -10, -10); btnBuy.setLayoutParams(btnParams); btnBuy.setText("Buy Now (" + strImgMsg + ")"); btnBuy.setBackgroundColor(MainActivity.getDominantColor(bitmap)); btnBuy.setTextColor(Color.WHITE); btnBuy.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { Intent newActivity = new Intent(getApplicationContext(), WebActivity.class); newActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); newActivity.putExtra("URL", "https://portal-battlehack.herokuapp.com/"); startActivity(newActivity); } }); layout.addView(imageview); layout.addView(btnBuy); MainActivity.myGallery.addView(layout); MainActivity.gal_size++; } }
From source file:com.example.lilach.alsweekathon_new.MainActivity.java
@Override public void onBackPressed() { if (mState == UART_PROFILE_CONNECTED) { Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startMain);// w ww .j a va2 s . c o m showMessage("nRFUART's running in background.\n Disconnect to exit"); } else { new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.popup_title) .setMessage(R.string.popup_message) .setPositiveButton(R.string.popup_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).setNegativeButton(R.string.popup_no, null).show(); } }
From source file:org.tomahawk.tomahawk_android.utils.TomahawkExceptionReporter.java
/** * Pull information from the given {@link CrashReportData} and send it via HTTP to * oops.tomahawk-player.org or sends it as a TEXT intent, if IS_SILENT is true *///w ww .j a v a 2 s . c o m @Override public void send(CrashReportData data) throws ReportSenderException { StringBuilder body = new StringBuilder(); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("Version", data.getProperty(ReportField.APP_VERSION_NAME))); nameValuePairs.add(new BasicNameValuePair("BuildID", data.getProperty(ReportField.BUILD))); nameValuePairs.add(new BasicNameValuePair("ProductName", "tomahawk-android")); nameValuePairs.add(new BasicNameValuePair("Vendor", "Tomahawk")); nameValuePairs.add(new BasicNameValuePair("timestamp", data.getProperty(ReportField.USER_CRASH_DATE))); for (NameValuePair pair : nameValuePairs) { body.append("--thkboundary\r\n"); body.append("Content-Disposition: form-data; name=\""); body.append(pair.getName()).append("\"\r\n\r\n").append(pair.getValue()).append("\r\n"); } body.append("--thkboundary\r\n"); body.append("Content-Disposition: form-data; name=\"upload_file_minidump\"; filename=\"") .append(data.getProperty(ReportField.REPORT_ID)).append("\"\r\n"); body.append("Content-Type: application/octet-stream\r\n\r\n"); body.append("============== Tomahawk Exception Report ==============\r\n\r\n"); body.append("Report ID: ").append(data.getProperty(ReportField.REPORT_ID)).append("\r\n"); body.append("App Start Date: ").append(data.getProperty(ReportField.USER_APP_START_DATE)).append("\r\n"); body.append("Crash Date: ").append(data.getProperty(ReportField.USER_CRASH_DATE)).append("\r\n\r\n"); body.append("--------- Phone Details ----------\r\n"); body.append("Phone Model: ").append(data.getProperty(ReportField.PHONE_MODEL)).append("\r\n"); body.append("Brand: ").append(data.getProperty(ReportField.BRAND)).append("\r\n"); body.append("Product: ").append(data.getProperty(ReportField.PRODUCT)).append("\r\n"); body.append("Display: ").append(data.getProperty(ReportField.DISPLAY)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("----------- Stack Trace -----------\r\n"); body.append(data.getProperty(ReportField.STACK_TRACE)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("------- Operating System ---------\r\n"); body.append("App Version Name: ").append(data.getProperty(ReportField.APP_VERSION_NAME)).append("\r\n"); body.append("Total Mem Size: ").append(data.getProperty(ReportField.TOTAL_MEM_SIZE)).append("\r\n"); body.append("Available Mem Size: ").append(data.getProperty(ReportField.AVAILABLE_MEM_SIZE)).append("\r\n"); body.append("Dumpsys Meminfo: ").append(data.getProperty(ReportField.DUMPSYS_MEMINFO)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("-------------- Misc ---------------\r\n"); body.append("Package Name: ").append(data.getProperty(ReportField.PACKAGE_NAME)).append("\r\n"); body.append("File Path: ").append(data.getProperty(ReportField.FILE_PATH)).append("\r\n"); body.append("Android Version: ").append(data.getProperty(ReportField.ANDROID_VERSION)).append("\r\n"); body.append("Build: ").append(data.getProperty(ReportField.BUILD)).append("\r\n"); body.append("Initial Configuration: ").append(data.getProperty(ReportField.INITIAL_CONFIGURATION)) .append("\r\n"); body.append("Crash Configuration: ").append(data.getProperty(ReportField.CRASH_CONFIGURATION)) .append("\r\n"); body.append("Settings Secure: ").append(data.getProperty(ReportField.SETTINGS_SECURE)).append("\r\n"); body.append("User Email: ").append(data.getProperty(ReportField.USER_EMAIL)).append("\r\n"); body.append("User Comment: ").append(data.getProperty(ReportField.USER_COMMENT)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("---------------- Logs -------------\r\n"); body.append("Logcat: ").append(data.getProperty(ReportField.LOGCAT)).append("\r\n\r\n"); body.append("Events Log: ").append(data.getProperty(ReportField.EVENTSLOG)).append("\r\n\r\n"); body.append("Radio Log: ").append(data.getProperty(ReportField.RADIOLOG)).append("\r\n"); body.append("-----------------------------------\r\n\r\n"); body.append("=======================================================\r\n\r\n"); body.append("--thkboundary\r\n"); body.append( "Content-Disposition: form-data; name=\"upload_file_tomahawklog\"; filename=\"Tomahawk.log\"\r\n"); body.append("Content-Type: text/plain\r\n\r\n"); body.append(data.getProperty(ReportField.LOGCAT)); body.append("\r\n--thkboundary--\r\n"); if ("true".equals(data.getProperty(ReportField.IS_SILENT))) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); body.insert(0, "Please tell us why you're sending us this log:\n\n\n\n\n"); intent.putExtra(Intent.EXTRA_TEXT, body.toString()); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "support@tomahawk-player.org" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Tomahawk Android Log"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); TomahawkApp.getContext().startActivity(intent); } else { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://oops.tomahawk-player.org/addreport.php"); httppost.setHeader("Content-type", "multipart/form-data; boundary=thkboundary"); try { httppost.setEntity(new StringEntity(body.toString())); httpclient.execute(httppost); } catch (ClientProtocolException e) { Log.e(TAG, "send: " + e.getClass() + ": " + e.getLocalizedMessage()); } catch (IOException e) { Log.e(TAG, "send: " + e.getClass() + ": " + e.getLocalizedMessage()); } } }
From source file:com.campusconnect.GoogleSignInActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_google); rootView = (LinearLayout) findViewById(R.id.main_layout); BitmapFactory.Options bm_opts = new BitmapFactory.Options(); bm_opts.inScaled = false;/*ww w . ja v a2s. c o m*/ Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.default_portrait_two, bm_opts); BitmapDrawable background = new BitmapDrawable(bitmap); rootView.setBackground(background); iv_branchProfileImage = (ImageView) findViewById(R.id.branch_profile_image); tv_branchUserName = (TextView) findViewById(R.id.branch_tv_username); try { String photourl = Branch.getInstance().getLatestReferringParams().getString("photourl"); if (photourl.isEmpty()) { iv_branchProfileImage.setImageResource(R.mipmap.ccnoti); } else { Picasso.with(GoogleSignInActivity.this).load(photourl).error(R.mipmap.ic_launcher) .memoryPolicy(MemoryPolicy.NO_CACHE).networkPolicy(NetworkPolicy.NO_CACHE) .placeholder(R.mipmap.ccnoti).into(iv_branchProfileImage); } tv_branchUserName.setText(Branch.getInstance().getLatestReferringParams().getString("profileName") + " " + "is Waiting For You"); iv_branchProfileImage.setVisibility(View.VISIBLE); tv_branchUserName.setVisibility(View.VISIBLE); } catch (JSONException e) { e.printStackTrace(); } if (!getIntent().hasExtra("logout")) { if (getSharedPreferences("CC", MODE_PRIVATE).contains("profileId")) { Intent home = new Intent(GoogleSignInActivity.this, HomeActivity2.class); home.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(home); finish(); } } firebaseAnalytics = FirebaseAnalytics.getInstance(this); // Views // mStatusTextView = (TextView) findViewById(R.id.status); // mDetailTextView = (TextView) findViewById(R.id.detail); // Button listeners findViewById(R.id.sign_in_button).setOnClickListener(this); findViewById(R.id.sign_out_button).setOnClickListener(this); findViewById(R.id.disconnect_button).setOnClickListener(this); // [START config_signin] // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build(); // [END config_signin] mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build(); // [START initialize_auth] mAuth = FirebaseAuth.getInstance(); // [END initialize_auth] // [START auth_state_listener] mAuthListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { FirebaseUser user = firebaseAuth.getCurrentUser(); if (user != null) { // User is signed in Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid()); } else { // User is signed out Log.d(TAG, "onAuthStateChanged:signed_out"); } // [START_EXCLUDE] updateUI(user); // [END_EXCLUDE] } }; // [END auth_state_listener] }
From source file:com.mobicage.rogerthat.registration.AbstractRegistrationActivity.java
public void startMainActivity(boolean directly) { if (!directly && AppConstants.PROFILE_SHOW_GENDER_AND_BIRTHDATE && !getAgeAndGenderSet()) { Intent intent = new Intent(mActivity, MainActivity.class); intent.setAction(MainActivity.ACTION_COMPLETE_PROFILE); intent.setFlags(MainActivity.FLAG_CLEAR_STACK_SINGLE_TOP); startActivity(intent);/*w ww .ja v a 2 s. c o m*/ } else { Intent intent = new Intent(mActivity, MainActivity.class); intent.setAction(MainActivity.ACTION_REGISTERED); startActivity(intent); } mActivity.finish(); }
From source file:com.novemser.voicetest.ui.MainActivity.java
@Override public boolean onNavigationItemSelected(MenuItem menuItem) { // Handle navigation view item clicks here. int id = menuItem.getItemId(); if (id == R.id.nav_alarm) { Intent intent = new Intent(MainActivity.this, AlarmListsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplicationContext().startActivity(intent); } else if (id == R.id.listen) { Intent intent = new Intent(MainActivity.this, VoiceRecActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplicationContext().startActivity(intent); }/*from w ww . ja v a2s .c om*/ DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }