make phone call, browse web, send email

// make phone call

try {
            Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse("tel:1850363744"));
            startActivity(callIntent);
        } catch (ActivityNotFoundException e) {
            Log.e("Dialing FAILED", "Call failed", e);
        }

 

try {

            Intent callIntent = new Intent(Intent.ACTION_CALL);

            callIntent.setData(Uri.parse("tel:+448450730099"));

            startActivity(callIntent);

        } catch (ActivityNotFoundException e) {

            Log.e("Dialing FAILED", "Call failed", e);

        }
// browse web

try {

            Intent webIntent = new Intent(Intent.ACTION_VIEW);

            webIntent.setData(Uri.parse("http://www.energia.ie"));

            startActivity(webIntent);

        } catch (ActivityNotFoundException e) {

            Log.e("Browsing FAILED", "Browser failed", e);

        } // send mail

try {

            Intent emailIntent = new Intent(Intent.ACTION_SENDTO);

           

            //Intent intent = new Intent(Intent.ACTION_SENDTO); // it's not ACTION_SEND

            emailIntent.setType("text/plain");

            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Contact Energia - Smart App");

            emailIntent.putExtra(Intent.EXTRA_TEXT, "");

            emailIntent.setData(Uri.parse("mailto:[email protected]")); // or just "mailto:" for blank

            emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this will make such that when user returns to your app, your app is displayed, instead of the email app.

            startActivity(emailIntent);

 

        } catch (ActivityNotFoundException e) {

            Log.e("Dialing FAILED", "Call failed", e);

        }


 

發佈了79 篇原創文章 · 獲贊 1 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章