Back to project page android_tutorial_projects.
The source code is released under:
Copyright (c) 2013, Uthcode All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redi...
If you think the Android project android_tutorial_projects listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.uthcode.implicitintents; //from w ww. ja v a 2s . c o m import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar; import android.support.v4.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.os.Build; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; public class CallIntentsActivity extends Activity { private Spinner spinner; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_call_intents); spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.intents, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); } public void onClick(View view) { int position = spinner.getSelectedItemPosition(); Intent intent = null; switch (position) { case 0: intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.uthcode.com")); break; case 1: intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:(+1)-650-516-MATH")); break; case 2: intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:(+1)-650-516-MATH")); break; case 3: intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:37.9266000,-122.0536000")); break; case 4: intent = new Intent("android.media.action.IMAGE_CAPTURE"); break; case 5: intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://contacts/people/")); break; case 6: intent = new Intent(Intent.ACTION_EDIT, Uri.parse("content://contacts/people/1")); break; } if (intent != null) { startActivity(intent); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK && requestCode == 0) { String result = data.toURI(); Toast.makeText(this, result, Toast.LENGTH_LONG); } } }