Example usage for android.content Intent addFlags

List of usage examples for android.content Intent addFlags

Introduction

In this page you can find the example usage for android.content Intent addFlags.

Prototype

public @NonNull Intent addFlags(@Flags int flags) 

Source Link

Document

Add additional flags to the intent (or with existing flags value).

Usage

From source file:app.clirnet.com.clirnetapp.activity.LoginActivity.java

private void showCreatePatientAlertDialog() {

    final Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.no_inetrnet_login_dialog);

    dialog.setTitle(/* w  w  w.  j  a va 2s. c  om*/
            "Your security credentials have expired. Please login with an active internet connection to refresh.");
    //  dialog.setCancelable(false);

    Button dialogButtonCancel = (Button) dialog.findViewById(R.id.customDialogCancel);
    Button dialogButtonOk = (Button) dialog.findViewById(R.id.customDialogOk);
    // Click cancel to dismiss android custom dialog box
    dialogButtonCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            dialog.dismiss();

        }
    });

    // Your android custom dialog ok action
    // Action for custom dialog ok button click
    dialogButtonOk.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);

            dialog.dismiss();

        }
    });

    dialog.show();

}

From source file:com.canappi.connector.yp.yhere.BakeryView.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent;
    switch (item.getItemId()) {

    case R.layout.searchview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, SearchView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);//from  ww  w.ja  v  a2s  . c om
        return true;

    case R.layout.restaurantview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, RestaurantView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.groceryview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, GroceryView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.gasstationview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, GasStationView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.theaterview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, TheaterView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.couponview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, CouponView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.lubeview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, LubeView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.gameview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, GameView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.bakeryview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, BakeryView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.repairview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, RepairView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.homeview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, HomeView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    case R.layout.settingsview:
        // app icon in Action Bar clicked; go home
        intent = new Intent(this, SettingsView.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.example.android.rowanparkingpass.Activities.PassActivity.java

@Override
public void onClick(View view) {
    Intent intent;
    if (view == startDate) {
        // Select Pass Start Date using a date selector
        startDatePickerDialog.show();//  w w w .j  a  v  a 2s .  c  o  m
    } else if (view == endDate) {
        // Select Pass End Date using a date selector
        endDatePickerDialog.show();
    } else {
        if (view == createPass) {
            //TODO Temp driver created the pass is still created with null null null
            if (NetworkCheck.haveNetworkConnection()) {
                new SendToServer().send();

                executeProcessRequest();
            } else {
                Toast.makeText(getApplicationContext(), "No Network Connection. Cannot create a pass.s",
                        Toast.LENGTH_LONG).show();
            }
        } else if (view == mainMenu) {
            // Goes back to main menu
            intent = new Intent(getApplicationContext(), PassesActivity.class);
            intent.putExtra(MODE, mode.HOME_PAGE.name());
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            finish();
        }
    }
}

From source file:me.willowcheng.makerthings.ui.OpenHABMainActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(TAG, String.format("onActivityResult requestCode = %d, resultCode = %d", requestCode, resultCode));
    switch (requestCode) {
    case SETTINGS_REQUEST_CODE:
        // Restart app after preferences
        Log.d(TAG, "Restarting after settings");
        // Get launch intent for application
        //                Intent restartIntent = getBaseContext().getPackageManager()
        //                        .getLaunchIntentForPackage(getBaseContext().getPackageName());
        Intent restartIntent = new Intent(this, OpenHABMainActivity.class);
        restartIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        // Finish current activity
        finish();//from  w  ww.  jav a  2 s  . c  om
        // Start launch activity
        startActivity(restartIntent);
        break;
    case WRITE_NFC_TAG_REQUEST_CODE:
        Log.d(TAG, "Got back from Write NFC tag");
        break;
    default:
    }
}

From source file:com.roamprocess1.roaming4world.syncadapter.SyncAdapter.java

private void updateOfflineMissedCalls() {

    String from_summary = "", noc = "", from_detailed = "", lt = "", ct = "";
    Cursor c;//from  w  ww.  j a  v a  2s.  co  m
    String time = "", value;
    try {

        dbContacts = new DBContacts(mcontext);
        //   dbContacts.openToWrite();
        dbContacts.openToRead();
        c = dbContacts.fetch_details_from_MIssedCall_Offline_Table();

        if (c.getCount() > 0) {
            c.moveToFirst();
            value = c.getString(2);
            time = "&time=" + value;
            //  time = "&time=" + "1408434902";
        }

        c.close();
        dbContacts.close();

        Log.d("webService App Resume", "called");
        HttpParams p = new BasicHttpParams();
        p.setParameter("user", "1");
        HttpClient httpclient = new DefaultHttpClient(p);
        String url = "http://ip.roaming4world.com/esstel/app_resume_info.php?contact="
                + prefs.getString(stored_user_country_code, "NoValue")
                + prefs.getString(stored_user_mobile_no, "NoValue") + time;

        Log.d("url", url + " #");

        HttpGet httpget = new HttpGet(url);
        ResponseHandler<String> responseHandler;
        String responseBody;
        responseHandler = new BasicResponseHandler();
        responseBody = httpclient.execute(httpget, responseHandler);

        dbContacts.openToWrite();

        JSONObject json = new JSONObject(responseBody);

        Log.d("response11", json + " #");

        if (json.getString("verify_from_pc").equals("true")) {
            Intent i = new Intent(mcontext, DesktopVerificationcode_Activity.class);
            i.putExtra("verify_code", json.getString("verify_code"));
            i.putExtra("countdown_time", json.getString("countdown_time"));
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mcontext.startActivity(i);
        }

        prefs.edit().putString(stored_min_call_credit, json.getString("min_call_credit")).commit();
        prefs.edit().putString(stored_user_bal, json.getString("user_bal")).commit();
        prefs.edit().putString(stored_server_ipaddress, json.getString("server_ip")).commit();

        Log.d("stored_server_ip address", json.getString("server_ip") + " #");
        Log.d("stored_user_bal", json.getString("user_bal") + " #");

        if (json.getString("valid").equals("true")) {

            JSONArray summary = json.getJSONArray("summary");
            JSONArray detailed = json.getJSONArray("detailed");

            for (int i = 0; i < summary.length(); i++) {
                JSONObject summarydata = summary.getJSONObject(i);
                from_summary = summarydata.getString("from");
                noc = summarydata.getString("noc");
                lt = summarydata.getString("lt");

                Log.d("from_summary", from_summary + " #");
                Log.d("noc", noc + " #");
                Log.d("lt", lt + " #");

                dbContacts.insert_MIssedCall_Offline_detail_in_db(from_summary, lt, noc);

                /*
                mBuilder.setSmallIcon(R.drawable.notification_icon);
                mBuilder.setContentTitle("Missed call (" + noc +")");
                mBuilder.setContentText(from_summary + "   " + lt);
                mBuilder.setContentIntent(resultPendingIntent);
                mNotificationManager.notify(Integer.parseInt(lt), mBuilder.build());
                */
                String count = "Missed call (" + noc + ")";

                CharSequence dateText = DateUtils.getRelativeTimeSpanString(Long.parseLong(lt) * 1000,
                        System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS,
                        DateUtils.FORMAT_ABBREV_RELATIVE);

                String num_date = from_summary + "   last on " + dateText.toString();

                showNotification(count, num_date, Integer.parseInt(lt));

            }

            for (int i = 0; i < detailed.length(); i++) {
                JSONObject detaileddata = detailed.getJSONObject(i);
                from_detailed = detaileddata.getString("from");
                ct = detaileddata.getString("ct");

                Log.d("from_detailed", from_detailed + " #");
                Log.d("ct", ct + " #");

                dbContacts.insert_MIssedCall_detail_in_db(from_detailed, ct);
            }

            dbContacts.close();

        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:com.appolis.move.AcMoveDetails.java

/**
 * Process event for views// w  w w  . jav  a2s.  com
 */
@Override
public void onClick(View v) {
    Intent intent;
    switch (v.getId()) {
    case R.id.imgHome:
        Utilities.hideKeyboard(this);
        intent = new Intent(AcMoveDetails.this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivityForResult(intent, GlobalParams.LOGINSCREEN_TO_MAINSCREEN);
        break;

    case R.id.img_main_menu_scan_barcode:
        intent = new Intent(this, CaptureBarcodeCamera.class);
        startActivityForResult(intent, GlobalParams.AC_MOVE_LEVEL_TWO);
        break;

    case R.id.btnCancel:
        finish();
        break;

    case R.id.btnOK:
        try {
            PostItemAsyncTask postItemAsyncTask = new PostItemAsyncTask();
            postItemAsyncTask.execute();
        } catch (Exception e) {

        }

        break;

    default:
        break;
    }
}

From source file:Main.java

public static void openFile(Context context, File url) throws IOException {
    // Create URI
    File file = url;//from  ww w .j  a v  a  2 s .c o  m
    Uri uri = Uri.fromFile(file);

    Intent intent = new Intent(Intent.ACTION_VIEW);
    // Check what kind of file you are trying to open, by comparing the url with extensions.
    // When the if condition is matched, plugin sets the correct intent (mime) type, 
    // so Android knew what application to use to open the file
    if (url.toString().contains(".doc") || url.toString().contains(".docx")) {
        // Word document
        intent.setDataAndType(uri, "application/msword");
    } else if (url.toString().contains(".pdf")) {
        // PDF file
        intent.setDataAndType(uri, "application/pdf");
    } else if (url.toString().contains(".ppt") || url.toString().contains(".pptx")) {
        // Powerpoint file
        intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
    } else if (url.toString().contains(".xls") || url.toString().contains(".xlsx")) {
        // Excel file
        intent.setDataAndType(uri, "application/vnd.ms-excel");
    } else if (url.toString().contains(".zip") || url.toString().contains(".rar")) {
        // WAV audio file
        intent.setDataAndType(uri, "application/zip");
    } else if (url.toString().contains(".rtf")) {
        // RTF file
        intent.setDataAndType(uri, "application/rtf");
    } else if (url.toString().contains(".wav") || url.toString().contains(".mp3")) {
        // WAV audio file
        intent.setDataAndType(uri, "audio/x-wav");
    } else if (url.toString().contains(".gif")) {
        // GIF file
        intent.setDataAndType(uri, "image/gif");
    } else if (url.toString().contains(".jpg") || url.toString().contains(".jpeg")
            || url.toString().contains(".png")) {
        // JPG file
        intent.setDataAndType(uri, "image/jpeg");
    } else if (url.toString().contains(".txt")) {
        // Text file
        intent.setDataAndType(uri, "text/plain");
    } else if (url.toString().contains(".3gp") || url.toString().contains(".mpg")
            || url.toString().contains(".mpeg") || url.toString().contains(".mpe")
            || url.toString().contains(".mp4") || url.toString().contains(".avi")) {
        // Video files
        intent.setDataAndType(uri, "video/*");
    } else {
        //if you want you can also define the intent type for any other file

        //additionally use else clause below, to manage other unknown extensions
        //in this case, Android will show all applications installed on the device
        //so you can choose which application to use
        intent.setDataAndType(uri, "*/*");
    }

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:RhodesService.java

@Override
public void startActivity(Intent intent) {

    RhodesActivity ra = RhodesActivity.getInstance();
    if (intent.getComponent() != null
            && intent.getComponent().compareTo(new ComponentName(this, RhodesActivity.class.getName())) == 0) {
        Logger.T(TAG, "Start or bring main activity: " + RhodesActivity.class.getName() + ".");
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        if (ra == null) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            super.startActivity(intent);
            return;
        }//from  www .ja  v  a2 s  .  com
    }

    if (ra != null) {
        Logger.T(TAG, "Starting new activity on top.");
        if (DEBUG) {
            Bundle extras = intent.getExtras();
            if (extras != null) {
                for (String key : extras.keySet()) {
                    Object val = extras.get(key);
                    if (val != null)
                        Log.d(TAG, key + ": " + val.toString());
                    else
                        Log.d(TAG, key + ": <empty>");
                }
            }
        }
        ra.startActivity(intent);
    } else {
        throw new IllegalStateException(
                "Trying to start activity, but there is no main activity instance (we are in background, no UI active)");
    }
}

From source file:Main.java

public static void openFileInExtApp(Context context, File url) throws IOException {
    // Create URI
    File file = url;/* w  w  w  .  j av a2s .c om*/
    Uri uri = Uri.fromFile(file);

    Intent intent = new Intent(Intent.ACTION_VIEW);
    // Check what kind of file you are trying to open, by comparing the url with extensions.
    // When the if condition is matched, plugin sets the correct intent (mime) type,
    // so Android knew what application to use to open the file
    if (url.toString().contains(".doc") || url.toString().contains(".docx")) {
        // Word document
        intent.setDataAndType(uri, "application/msword");
    } else if (url.toString().contains(".pdf")) {
        // PDF file
        intent.setDataAndType(uri, "application/pdf");
    } else if (url.toString().contains(".ppt") || url.toString().contains(".pptx")) {
        // Powerpoint file
        intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
    } else if (url.toString().contains(".xls") || url.toString().contains(".xlsx")) {
        // Excel file
        intent.setDataAndType(uri, "application/vnd.ms-excel");
    } else if (url.toString().contains(".zip") || url.toString().contains(".rar")) {
        // WAV audio file
        intent.setDataAndType(uri, "application/x-wav");
    } else if (url.toString().contains(".rtf")) {
        // RTF file
        intent.setDataAndType(uri, "application/rtf");
    } else if (url.toString().contains(".wav") || url.toString().contains(".mp3")) {
        // WAV audio file
        intent.setDataAndType(uri, "audio/x-wav");
    } else if (url.toString().contains(".gif")) {
        // GIF file
        intent.setDataAndType(uri, "image/gif");
    } else if (url.toString().contains(".jpg") || url.toString().contains(".jpeg")
            || url.toString().contains(".png")) {
        // JPG file
        intent.setDataAndType(uri, "image/jpeg");
    } else if (url.toString().contains(".txt")) {
        // Text file
        intent.setDataAndType(uri, "text/plain");
    } else if (url.toString().contains(".html")) {
        // Html file
        intent.setDataAndType(uri, "text/html");
    } else if (url.toString().contains(".3gp") || url.toString().contains(".mpg")
            || url.toString().contains(".mpeg") || url.toString().contains(".mpe")
            || url.toString().contains(".mp4") || url.toString().contains(".avi")) {
        // Video files
        intent.setDataAndType(uri, "video/*");
    } else {
        //if you want you can also define the intent type for any other file

        //additionally use else clause below, to manage other unknown extensions
        //in this case, Android will show all applications installed on the device
        //so you can choose which application to use
        intent.setDataAndType(uri, "*/*");
    }

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}