Example usage for android.content Intent EXTRA_SUBJECT

List of usage examples for android.content Intent EXTRA_SUBJECT

Introduction

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

Prototype

String EXTRA_SUBJECT

To view the source code for android.content Intent EXTRA_SUBJECT.

Click Source Link

Document

A constant string holding the desired subject line of a message.

Usage

From source file:com.gh4a.activities.GistActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.share:
        String login = ApiHelpers.getUserLogin(this, mGist.getOwner());
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_gist_subject, mGistId, login));
        shareIntent.putExtra(Intent.EXTRA_TEXT, mGist.getHtmlUrl());
        shareIntent = Intent.createChooser(shareIntent, getString(R.string.share_title));
        startActivity(shareIntent);/*from   w  w w  . j a  v  a 2s  . c o m*/
        return true;
    case R.id.star:
        MenuItemCompat.setActionView(item, R.layout.ab_loading);
        MenuItemCompat.expandActionView(item);
        new UpdateStarTask().schedule();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.agateau.equiv.ui.Kernel.java

public void shareCustomProductList(Context context) {
    File file = context.getFileStreamPath(CUSTOM_PRODUCTS_CSV);
    Uri contentUri = FileProvider.getUriForFile(context, "com.agateau.equiv.fileprovider", file);
    final Resources res = context.getResources();

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.CUSTOM_PRODUCTS_EMAIL });
    intent.putExtra(Intent.EXTRA_SUBJECT, res.getString(R.string.share_email_subject));
    intent.putExtra(Intent.EXTRA_STREAM, contentUri);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    context.startActivity(Intent.createChooser(intent, res.getString(R.string.share_via)));
}

From source file:com.picogram.awesomeness.SettingsActivity.java

public boolean onPreferenceClick(final Preference preference) {
    if (preference.getKey().equals("statistics")) {
        //TODO/*  w ww . ja v  a  2s .  com*/
        Crouton.makeText(this, "This is not yet implemented", Style.INFO).show();
        final AlertDialog dialog = new AlertDialog.Builder(this).create();
        final String[] scoresTitles = new String[] { "Games Played", "Games Won", "Taps", "Taps per Puzzle",
                "Tapes per Minute", "Times Played" };
        final int gamesPlayed = 0, gamesWon = 0, taps = 0, tapsPerPuzzle = 0, tapsPerMinute = 0, timePlayed = 0;
        final int[] scores = { gamesPlayed, gamesWon, taps, tapsPerPuzzle, tapsPerMinute, timePlayed };
        // TODO: Implement the preferences and what not.
        final LinearLayout ll = new LinearLayout(this);
        ll.setOrientation(LinearLayout.VERTICAL);
        for (int i = 0; i != scores.length; ++i) {
            final LinearLayout sub = new LinearLayout(this);
            sub.setLayoutParams(new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,
                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
            sub.setOrientation(LinearLayout.HORIZONTAL);
            TextView tv = new TextView(this);
            tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
            tv.setText(scoresTitles[i]);
            sub.addView(tv);
            tv = new TextView(this);
            tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
            tv.setText(scores[i] + "");
            sub.addView(tv);
            ll.addView(sub);
        }
        dialog.setView(ll);
        dialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(final DialogInterface dialog, final int which) {
                dialog.dismiss();
            }
        });
        dialog.getWindow().getAttributes().windowAnimations = R.style.DialogTheme;
        dialog.show();
        dialog.dismiss();

        return true;
    } else if (preference.getKey().equals("changelog")) {
        // Launch change log dialog
        final ChangeLogDialog _ChangelogDialog = new ChangeLogDialog(this);
        _ChangelogDialog.show();
    } else if (preference.getKey().equals("licenses")) {
        // Launch the licenses stuff.
        Dialog ld = new LicensesDialog(this, R.raw.licenses, false, false).create();
        ld.getWindow().getAttributes().windowAnimations = R.style.DialogTheme;
        ld.show();
    } else if (preference.getKey().equals("email")) {
        final String email = "warner.73+Picogram@wright.edu";
        final String subject = "Picogram - <SUBJECT>";
        final String message = "Picogram,\n\n<MESSAGE>";
        // Contact me.
        final Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { email });
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        emailIntent.putExtra(Intent.EXTRA_TEXT, message);
        emailIntent.setType("message/rfc822");
        this.startActivity(Intent.createChooser(emailIntent, "Send Mail Using :"));
        overridePendingTransition(R.anim.fadein, R.anim.exit_left);
    } else if (preference.getKey().equals("rateapp")) {
        // TODO fix this when we publish.
        this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=Picogram")));
        overridePendingTransition(R.anim.fadein, R.anim.exit_left);
        final Editor editor = this.prefs.edit();
        editor.putBoolean(RateMeMaybe.PREF.DONT_SHOW_AGAIN, true);
        editor.commit();
    } else if (preference.getKey().equals("logoutgoogle")) {
        //TODO
        Crouton.makeText(this, "This is not currently supported.", Style.INFO).show();
    } else if (preference.getKey().equals("logoutfacebook")) {
        //TODO
        Crouton.makeText(this, "This is not currently supported.", Style.INFO).show();
    } else if (preference.getKey().equals("resetusername")) {
        Util.getPreferences(this).edit().putString("username", "").commit();
        Util.getPreferences(this).edit().putBoolean("hasLoggedInUsername", false).commit();
    }
    return false;
}

From source file:ch.luklanis.esscan.history.HistoryActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.history_menu_send_dta_save:
    case R.id.history_menu_send_dta_other:
    case R.id.history_menu_send_dta_email: {
        Message message = Message.obtain(mDataSentHandler, item.getItemId());
        createDTAFile(message);// w ww.j  av a2s  . c  om
    }
        break;
    case R.id.history_menu_send_csv: {
        CharSequence history = mHistoryManager.buildHistory();
        Uri historyFile = HistoryManager.saveHistory(history.toString());

        String[] recipients = new String[] { PreferenceManager.getDefaultSharedPreferences(this)
                .getString(PreferencesActivity.KEY_EMAIL_ADDRESS, "") };

        if (historyFile == null) {
            setOkAlert(R.string.msg_unmount_usb);
        } else {
            Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
            intent.putExtra(Intent.EXTRA_EMAIL, recipients);
            String subject = getResources().getString(R.string.history_email_title);
            intent.putExtra(Intent.EXTRA_SUBJECT, subject);
            intent.putExtra(Intent.EXTRA_TEXT, subject);
            intent.putExtra(Intent.EXTRA_STREAM, historyFile);
            intent.setType("text/csv");
            startActivity(intent);
        }
    }
        break;
    case R.id.history_menu_clear: {
        new CancelOkDialog(R.string.msg_sure).setOkClickListener(new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                mHistoryManager.clearHistory();
                dialogInterface.dismiss();
                finish();
            }
        }).show(getFragmentManager(), "HistoryActivity.onOptionsItemSelected");
    }
        break;
    case android.R.id.home: {

        int error = PsDetailActivity.savePaymentSlip(this);

        if (error > 0) {
            setCancelOkAlert(this, error);
            return true;
        }

        NavUtils.navigateUpTo(this, new Intent(this, CaptureActivity.class));
        return true;
    }
    case R.id.history_menu_copy_code_row: {
        PsDetailFragment fragment = (PsDetailFragment) getFragmentManager()
                .findFragmentById(R.id.ps_detail_container);

        if (fragment != null) {
            String completeCode = fragment.getHistoryItem().getResult().getCompleteCode();

            addCodeRowToClipboard(completeCode);
        }
    }
        break;
    case R.id.history_menu_send_code_row: {
        PsDetailFragment fragment = (PsDetailFragment) getFragmentManager()
                .findFragmentById(R.id.ps_detail_container);

        if (fragment != null) {
            IEsrSender sender = getEsrSender();

            if (sender != null) {
                mSendingProgressDialog.show();

                fragment.send(PsDetailFragment.SEND_COMPONENT_CODE_ROW, sender,
                        this.historyFragment.getActivatedPosition());
            } else {
                Message message = Message.obtain(mDataSentHandler, R.id.es_send_failed);
                message.sendToTarget();
            }
        }
    }
        break;
    default:
        return super.onOptionsItemSelected(item);
    }
    return true;
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedActionsFragment.java

private void sendToExternalFriend() {
    Intent share = new Intent(Intent.ACTION_SEND);
    share.putExtra(Intent.EXTRA_TEXT,/*from  w w w  .j  a  va 2 s  .  c  om*/
            "Join me in a Musubi thread: " + ThreadRequest.getInvitationUri(getActivity(), mExternalFeedUri));
    share.putExtra(Intent.EXTRA_SUBJECT, "Join me on Musubi!");
    share.setType("text/plain");
    startActivity(share);
}

From source file:com.z.stproperty.PropertyDetailFragment.java

/**
 * onClick   :: OnClickListener/*ww  w.  ja v a 2  s .  c  o  m*/
 * 
 * Is common on-click listener for all the buttons and images in home screen
 * This is grouped into single listener to make easier to alter the code and reduce the 
 * line of code.
 * 
 * This will check the View ID to match with the predefined View-ID to identify
 * which view is clicked 
 * 
 * Based on the view id this will perform different functionalities 
 */
private void performClickAction(View v) {
    try {
        switch (v.getId()) {
        case R.id.LoanCalculator:
            Intent calIntent = new Intent(getActivity(), LoanCalculator.class);
            calIntent.putExtra("price", price);
            startActivity(calIntent);
            break;
        case R.id.AgentMobile:
            String url = "tel:" + mobileNoStr;
            url = url.replace("+65-", "");
            Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse(url));
            startActivity(callIntent);
            break;
        case R.id.SendEmailBtn:
            String text = "I'm interested in your property advertised on STProperty\n\n" + "PROPERTY TITLE:"
                    + title + "\n" + "PRICE:" + price
                    + "\n\nClick on the following link to view more details about the property\n\n" + prurl;

            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("plain/text");
            intent.putExtra(Intent.EXTRA_EMAIL, new String[] { agentEmail });
            intent.putExtra(Intent.EXTRA_SUBJECT, "Enquiry");
            intent.putExtra(Intent.EXTRA_TEXT, text);
            SharedFunction.postAnalytics(PropertyDetailFragment.this.getActivity(), "Lead",
                    "Successful Email Enquiry", title);
            startActivity(Intent.createChooser(intent, ""));
            break;
        /**case R.id.SendEnquiryBtn:
           Intent enqInt = new Intent(getActivity(), SaleEnquiry.class);
           enqInt.putExtra("propertyId", detailsJson.getString("id"));
           enqInt.putExtra("agentId", detailsJson.getJSONObject("seller_info").getString("agent_cea_reg_no"));
           startActivity(enqInt);
           break;*/
        default:
            break;
        }
    } catch (Exception e) {
        Log.e(this.getClass().getSimpleName(), e.getLocalizedMessage(), e);
    }
}

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
 *//*from w  ww. j  ava2s  .c om*/
@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.elekso.potfix.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    PowerManager pm = (PowerManager) getApplicationContext()
            .getSystemService(getApplicationContext().POWER_SERVICE);
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, " POTFIX holding wake lock");
    wl.acquire();//from w w w  .  j av  a 2s  .  co m
    Globals.getInstance().setFlexiblemap(true);

    //
    //
    //        new Thread(new Runnable(){
    //            @Override
    //            public void run() {
    //                try {
    //                    LALpotfixservicePortBinding service = new LALpotfixservicePortBinding();
    //                    try {
    //                        globaldata_test=service.CheckWS("mandar");
    //
    //                    } catch (Exception e) {
    //                        e.printStackTrace();
    //                    }
    //                } catch (Exception ex) {
    //                    ex.printStackTrace();
    //                }
    //            }
    //        }).start();

    String login = "";

    //  Config.getInstance(getBaseContext(),getCacheDir()).setProfile("df","asd");
    login = Config.getInstance(getBaseContext(), getCacheDir()).getProfileName();
    if (login == null || login.isEmpty()) {
        Intent intent = new Intent(this, LoginActivity.class);
        startActivity(intent);
        return;
    }
    //remove
    //  Stetho.initializeWithDefaults(this);

    // Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Drawer
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    tusername = (TextView) drawer.findViewById(R.id.tvusername);
    //        tuseremail =(TextView) findViewById(R.id.tvuseremail);
    //
    //        if(login!=null)
    //            tusername.setText("jhjhjhjh");
    //   if(Config.getInstance().getProfileEmail()!=null)
    //tuseremail.setText(Config.getInstance().getProfileEmail());

    // FAB
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setRippleColor(Color.parseColor("#78D6F3"));
    fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#039FDC")));
    fab.setImageResource(R.drawable.ic_gps_fixed_white_24dp);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (currentFragment) {
            case 1: //profile
                Snackbar.make(view, "Updating Information", Snackbar.LENGTH_LONG).setAction("Action", null)
                        .show();
                Fragment frg = new ProfileFragment();
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.replace(R.id.frame_containerone, frg);
                transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
                transaction.commit();
                break;
            case 2: //map

                if (Globals.getInstance().getFlexiblemap()) {
                    Snackbar.make(view, "Free to Scroll", Snackbar.LENGTH_LONG).setAction("Action", null)
                            .show();
                    Globals.getInstance().setFlexiblemap(false);
                    fab.setRippleColor(Color.parseColor("#FFE082"));
                    fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#FFB300")));
                    fab.setImageResource(R.drawable.ic_gps_off_white_24dp);
                } else {
                    Snackbar.make(view, "Follow Potfix", Snackbar.LENGTH_LONG).setAction("Action", null).show();
                    Globals.getInstance().setFlexiblemap(true);
                    fab.setRippleColor(Color.parseColor("#78D6F3"));
                    fab.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#039FDC")));
                    fab.setImageResource(R.drawable.ic_gps_fixed_white_24dp);
                }
                break;
            case 3: //share
                //Snackbar.make(view, "Some sharing action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
                String[] TO = { "aziz@potfix.com" };
                String[] CC = { "" };
                Intent emailIntent = new Intent(Intent.ACTION_SEND);

                emailIntent.setData(Uri.parse("mailto:"));
                emailIntent.setType("text/plain");
                emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
                emailIntent.putExtra(Intent.EXTRA_CC, CC);
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Potfix Communication");
                emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message...");

                try {
                    startActivity(Intent.createChooser(emailIntent, "Send mail..."));
                    finish();
                } catch (android.content.ActivityNotFoundException ex) {
                    Toast.makeText(MainActivity.this, "There is no email client installed.", Toast.LENGTH_SHORT)
                            .show();
                }
                break;
            case 4: //legal
                Snackbar.make(view, "Software License", Snackbar.LENGTH_LONG).setAction("Action", null).show();
                drawer.openDrawer(Gravity.LEFT);
                break;
            }

        }
    });

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    startService(new Intent(getBaseContext(), BackgroundService.class));

    FragmentTransaction mTransaction = getSupportFragmentManager().beginTransaction();
    MapsFragment mFRaFragment = new MapsFragment();
    mTransaction.add(R.id.frame_containerone, mFRaFragment);
    mTransaction.commit();

    LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

    if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        Toast.makeText(this, "GPS is Enabled in your devide", Toast.LENGTH_SHORT).show();
    } else {
        showGPSDisabledAlertToUser();
    }

    //        if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){
    //            Toast.makeText(this, "Network is Enabled in your devide", Toast.LENGTH_SHORT).show();
    //        }else{
    //            showNetDisabledAlertToUser();
    //        }
    createNotification();
}

From source file:com.galois.qrstream.MainActivity.java

private Job buildJobFromIntent(Intent intent) throws IllegalArgumentException {
    String type = intent.getType();
    Bundle extras = intent.getExtras();// w  w w . j  a v  a  2  s  .  c o m
    Log.d(Constants.APP_TAG, "** received type " + type);

    String name = "";
    byte[] bytes = null;

    Uri dataUrl = (Uri) intent.getExtras().getParcelable(Intent.EXTRA_STREAM);
    if (dataUrl != null) {
        name = getNameFromURI(dataUrl);
        if (dataUrl.getScheme().equals("content") || dataUrl.getScheme().equals("file")) {
            try {
                bytes = readFileUri(dataUrl);
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            Log.d(Constants.APP_TAG, "unsupported url: " + dataUrl);
        }
    } else {
        // fall back to content in extras (mime type dependent)
        if (type.equals("text/plain")) {
            String subject = extras.getString(Intent.EXTRA_SUBJECT);
            String text = extras.getString(Intent.EXTRA_TEXT);
            if (subject == null) {
                bytes = text.getBytes();
            } else {
                bytes = encodeSubjectAndText(subject, text);
                type = Constants.MIME_TYPE_TEXT_NOTE;
            }
        }
    }
    return new Job(name, bytes, type);
}

From source file:com.atahani.telepathy.ui.fragment.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View customLayout = inflater.inflate(R.layout.fragment_about_dialog, null);
    //config app version information
    mAppPreferenceTools = new AppPreferenceTools(TApplication.applicationContext);
    AppCompatTextView txAndroidAppVerInfo = (AppCompatTextView) customLayout
            .findViewById(R.id.tx_android_ver_info);
    txAndroidAppVerInfo.setText(String.format(getString(R.string.label_telepathy_for_android),
            mAppPreferenceTools.getTheLastAppVersion()));
    txAndroidAppVerInfo.setOnClickListener(new View.OnClickListener() {
        @Override// ww w. j a v a 2  s .c om
        public void onClick(View v) {
            try {
                //open browser to navigate telepathy website
                Uri telepathyWebSiteUri = Uri.parse("https://github.com/atahani/telepathy-android.git");
                startActivity(new Intent(Intent.ACTION_VIEW, telepathyWebSiteUri));
                ((TelepathyBaseActivity) getActivity()).setAnimationOnStart();
            } catch (Exception ex) {
                AndroidUtilities.processApplicationError(ex, true);
                if (isAdded() && getActivity() != null) {
                    Snackbar.make(getActivity().findViewById(android.R.id.content),
                            getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show();
                }
            }
        }
    });
    //config google play store link
    AppCompatTextView txRateUsOnGooglePlayStore = (AppCompatTextView) customLayout
            .findViewById(R.id.tx_rate_us_on_play_store);
    txRateUsOnGooglePlayStore.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //navigate to market for rate application
            Uri uri = Uri.parse("market://details?id=" + TApplication.applicationContext.getPackageName());
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
            // To count with Play market backstack, After pressing back button,
            // to taken back to our application, we need to add following flags to intent.
            goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
            try {
                startActivity(goToMarket);
                ((TelepathyBaseActivity) getActivity()).setAnimationOnStart();
            } catch (ActivityNotFoundException e) {
                startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id="
                                + TApplication.applicationContext.getPackageName())));
            }
        }
    });
    //config twitter link
    AppCompatTextView txTwitterLink = (AppCompatTextView) customLayout.findViewById(R.id.tx_twitter_telepathy);
    txTwitterLink.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                // If Twitter app is not installed, start browser.
                Uri twitterUri = Uri.parse("http://twitter.com/");
                startActivity(new Intent(Intent.ACTION_VIEW, twitterUri));
                ((TelepathyBaseActivity) getActivity()).setAnimationOnStart();
            } catch (Exception ex) {
                AndroidUtilities.processApplicationError(ex, true);
                if (isAdded() && getActivity() != null) {
                    Snackbar.make(getActivity().findViewById(android.R.id.content),
                            getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show();
                }
            }
        }
    });
    //config privacy link
    AppCompatTextView txPrivacyLink = (AppCompatTextView) customLayout.findViewById(R.id.tx_privacy);
    txPrivacyLink.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                //open browser to navigate privacy link
                Uri privacyPolicyUri = Uri
                        .parse("https://github.com/atahani/telepathy-android/blob/master/LICENSE.md");
                startActivity(new Intent(Intent.ACTION_VIEW, privacyPolicyUri));
                ((TelepathyBaseActivity) getActivity()).setAnimationOnStart();
            } catch (Exception ex) {
                AndroidUtilities.processApplicationError(ex, true);
                if (isAdded() && getActivity() != null) {
                    Snackbar.make(getActivity().findViewById(android.R.id.content),
                            getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show();
                }
            }
        }
    });
    //config report bug to open mail application and send bugs report
    AppCompatTextView txReportBug = (AppCompatTextView) customLayout.findViewById(R.id.tx_report_bug);
    txReportBug.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                final Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
                emailIntent.setType("plain/text");
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                        getString(R.string.label_report_bug_email_subject));
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailDeviceInformation());
                emailIntent.setData(Uri.parse("mailto:" + getString(R.string.telepathy_report_bug_email)));
                startActivity(Intent.createChooser(emailIntent,
                        getString(R.string.label_report_bug_choose_mail_app)));
                ((TelepathyBaseActivity) getActivity()).setAnimationOnStart();
            } catch (Exception ex) {
                AndroidUtilities.processApplicationError(ex, true);
                if (isAdded() && getActivity() != null) {
                    Snackbar.make(getActivity().findViewById(android.R.id.content),
                            getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show();
                }
            }
        }
    });
    //config the about footer image view
    AboutFooterImageView footerImageView = (AboutFooterImageView) customLayout
            .findViewById(R.id.im_delete_user_account);
    footerImageView.setTouchOnImageViewEventListener(new AboutFooterImageView.touchOnImageViewEventListener() {
        @Override
        public void onDoubleTab() {
            try {
                //confirm account delete via alert dialog
                final AlertDialog.Builder confirmAccountDeleteDialog = new AlertDialog.Builder(getActivity());
                confirmAccountDeleteDialog.setTitle(getString(R.string.label_delete_user_account));
                confirmAccountDeleteDialog
                        .setMessage(getString(R.string.label_delete_user_account_description));
                confirmAccountDeleteDialog.setNegativeButton(getString(R.string.action_no), null);
                confirmAccountDeleteDialog.setPositiveButton(getString(R.string.action_yes),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                //ok to delete account action
                                final ProgressDialog progressDialog = new ProgressDialog(getActivity());
                                progressDialog.setCancelable(false);
                                progressDialog.setCanceledOnTouchOutside(false);
                                progressDialog
                                        .setMessage(getString(R.string.re_action_on_deleting_user_account));
                                progressDialog.show();
                                TService tService = ((TelepathyBaseActivity) getActivity()).getTService();
                                tService.deleteUserAccount(new Callback<TOperationResultModel>() {
                                    @Override
                                    public void success(TOperationResultModel tOperationResultModel,
                                            Response response) {
                                        if (getActivity() != null && isAdded()) {
                                            //broad cast to close all of the realm  instance
                                            Intent intentToCloseRealm = new Intent(
                                                    Constants.TELEPATHY_BASE_ACTIVITY_INTENT_FILTER);
                                            intentToCloseRealm.putExtra(Constants.ACTION_TO_DO_PARAM,
                                                    Constants.CLOSE_REALM_DB);
                                            LocalBroadcastManager.getInstance(getActivity())
                                                    .sendBroadcastSync(intentToCloseRealm);
                                            mAppPreferenceTools.removeAllOfThePref();
                                            //                                 for sign out google first build GoogleAPIClient
                                            final GoogleApiClient googleApiClient = new GoogleApiClient.Builder(
                                                    TApplication.applicationContext)
                                                            .addApi(Auth.GOOGLE_SIGN_IN_API).build();
                                            googleApiClient.connect();
                                            googleApiClient.registerConnectionCallbacks(
                                                    new GoogleApiClient.ConnectionCallbacks() {
                                                        @Override
                                                        public void onConnected(Bundle bundle) {
                                                            Auth.GoogleSignInApi.signOut(googleApiClient)
                                                                    .setResultCallback(
                                                                            new ResultCallback<Status>() {
                                                                                @Override
                                                                                public void onResult(
                                                                                        Status status) {
                                                                                    //also revoke google access
                                                                                    Auth.GoogleSignInApi
                                                                                            .revokeAccess(
                                                                                                    googleApiClient)
                                                                                            .setResultCallback(
                                                                                                    new ResultCallback<Status>() {
                                                                                                        @Override
                                                                                                        public void onResult(
                                                                                                                Status status) {
                                                                                                            progressDialog
                                                                                                                    .dismiss();
                                                                                                            TelepathyBaseActivity currentActivity = (TelepathyBaseActivity) TApplication.mCurrentActivityInApplication;
                                                                                                            if (currentActivity != null) {
                                                                                                                Intent intent = new Intent(
                                                                                                                        TApplication.applicationContext,
                                                                                                                        SignInActivity.class);
                                                                                                                intent.setFlags(
                                                                                                                        Intent.FLAG_ACTIVITY_CLEAR_TASK
                                                                                                                                | Intent.FLAG_ACTIVITY_NEW_TASK);
                                                                                                                currentActivity
                                                                                                                        .startActivity(
                                                                                                                                intent);
                                                                                                                currentActivity
                                                                                                                        .setAnimationOnStart();
                                                                                                                currentActivity
                                                                                                                        .finish();
                                                                                                            }
                                                                                                        }
                                                                                                    });
                                                                                }
                                                                            });
                                                        }

                                                        @Override
                                                        public void onConnectionSuspended(int i) {
                                                            //do nothing
                                                        }
                                                    });
                                        }
                                    }

                                    @Override
                                    public void failure(RetrofitError error) {
                                        progressDialog.dismiss();
                                        if (getActivity() != null && isAdded()) {
                                            CommonFeedBack commonFeedBack = new CommonFeedBack(
                                                    getActivity().findViewById(android.R.id.content),
                                                    getActivity());
                                            commonFeedBack.checkCommonErrorAndBackUnCommonOne(error);
                                        }
                                    }
                                });
                            }
                        });
                confirmAccountDeleteDialog.show();
            } catch (Exception ex) {
                AndroidUtilities.processApplicationError(ex, true);
                if (isAdded() && getActivity() != null) {
                    Snackbar.make(getActivity().findViewById(android.R.id.content),
                            getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show();
                }
            }
        }
    });
    builder.setView(customLayout);
    return builder.create();
}