// initialize the progress dialog like in the first example // this is how you fire the downloader mProgressDialog.show(); Intent intent = new Intent(this, DownloadService.class); intent.putExtra("url", "url of the file to download"); intent.putExtra("receiver", new DownloadReceiver(new Handler())); startService(intent);
private void openScreenshot(File imageFile) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Uri uri = Uri.fromFile(imageFile); intent.setDataAndType(uri, "image/*"); startActivity(intent); }
Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); File file = new File(YOUR_SONG_URI); intent.setDataAndType(Uri.fromFile(file), "audio/*"); startActivity(intent);
Intent intent = new Intent("com.android.camera.action.CROP"); intent.setClassName("com.android.camera", "com.android.camera.CropImage"); File file = new File(filePath); Uri uri = Uri.fromFile(file); intent.setData(uri); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", 96); intent.putExtra("outputY", 96); intent.putExtra("noFaceDetection", true); intent.putExtra("return-data", true); startActivityForResult(intent, REQUEST_CROP_ICON);
Intent intent = new Intent(this,MyAppWidgetProvider.class); intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); // Use an array and EXTRA_APPWIDGET_IDS instead of AppWidgetManager.EXTRA_APPWIDGET_ID, // since it seems the onUpdate() is only fired on that: int[] ids = {widgetId}; intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS,ids); sendBroadcast(intent);
public static void addToPocket(Context context, String url, String tweetStatusId) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setPackage(PACKAGE); intent.setType(MIME_TYPE); intent.putExtra(Intent.EXTRA_TEXT, url); if (tweetStatusId != null && tweetStatusId.length() > 0) { intent.putExtra(EXTRA_TWEET_STATUS_ID, tweetStatusId); } intent.putExtra(EXTRA_SOURCE_PACKAGE, context.getPackageName()); context.startActivity(intent); }
public void onBackPressed() { Intent intent = new Intent(); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent i=new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (savedInstanceState==null) { File dir=getExternalFilesDir(Environment.DIRECTORY_DCIM); dir.mkdirs(); output=new File(dir, FILENAME); } else { output=(File)savedInstanceState.getSerializable(EXTRA_FILENAME); } if (output.exists()) { output.delete(); } i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(output)); startActivityForResult(i, CONTENT_REQUEST); }
Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + "/sdcard/test.jpg"), "image/*"); startActivity(intent);
ImageView img = (ImageView)findViewById(R.id.foo_bar); img.setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse("http://casidiablo.net")); startActivity(intent); } });