List of usage examples for android.content Intent addCategory
public @NonNull Intent addCategory(String category)
From source file:com.phonegap.plugins.wsiCameraLauncher.WsiCameraLauncher.java
/** * Get image from photo library.// ww w .j a va 2 s.c o m * * @param quality * Compression quality hint (0-100: 0=low quality & high * compression, 100=compress of max quality) * @param srcType * The album to get image from. * @param returnType * Set the type of image to return. */ // TODO: Images selected from SDCARD don't display correctly, but from // CAMERA ALBUM do! public void getImage(int srcType, int returnType) { final int srcTypeFinal = srcType; final int returnTypeFinal = returnType; String[] choices = { "Upload a Photo", "Upload a Video" }; AlertDialog.Builder builder = new AlertDialog.Builder(this.cordova.getActivity()); builder.setItems(choices, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Log.d(LOG_TAG, "Index #" + which + " chosen."); Intent intent = new Intent(); if (which == 0) { // set up photo intent WsiCameraLauncher.this.mediaType = PICTURE; intent.setType("image/*"); } else if (which == 1) { // set up video intent WsiCameraLauncher.this.mediaType = VIDEO; intent.setType("video/*"); } else { WsiCameraLauncher.this.failPicture("Selection cancelled."); return; } intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); if (WsiCameraLauncher.this.cordova != null) { WsiCameraLauncher.this.cordova.startActivityForResult((CordovaPlugin) WsiCameraLauncher.this, Intent.createChooser(intent, new String("Pick")), (srcTypeFinal + 1) * 16 + returnTypeFinal + 1); } } }); builder.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) { dialog.cancel(); WsiCameraLauncher.this.failPicture("Selection cancelled."); return true; } return false; } }); builder.show(); }
From source file:cn.kangeqiu.kq.activity.ChatActivity.java
/** * /* w w w . jav a 2 s .c o m*/ */ private void selectFileFromLocal() { Intent intent = null; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); } else { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } startActivityForResult(intent, REQUEST_CODE_SELECT_FILE); }
From source file:com.cardio3g.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); Fabric.with(this, new Crashlytics()); setContentView(R.layout.activity_main); mDownloadViewGroup = (RelativeLayout) findViewById(R.id.downloadViewGroup); mDownloadProgressBar = (ProgressBar) findViewById(R.id.downloadProgressBar); mProgressPercentTextView = (TextView) findViewById(R.id.downloadProgressPercentTextView); mainLayout = (RelativeLayout) findViewById(R.id.mainLayout); mDownloaderClientStub = DownloaderClientMarshaller.CreateStub(this, DownloaderService.class); if (!expansionFilesDelivered()) { try {/* www . j a v a 2 s.com*/ Intent launchIntent = MainActivity.this.getIntent(); Intent intentToLaunchThisActivityFromNotification = new Intent(MainActivity.this, MainActivity.this.getClass()); intentToLaunchThisActivityFromNotification .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); intentToLaunchThisActivityFromNotification.setAction(launchIntent.getAction()); if (launchIntent.getCategories() != null) { for (String category : launchIntent.getCategories()) { intentToLaunchThisActivityFromNotification.addCategory(category); } } // Build PendingIntent used to open this activity from // Notification PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, 0, intentToLaunchThisActivityFromNotification, PendingIntent.FLAG_UPDATE_CURRENT); // Request to start the download int startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(this, pendingIntent, DownloaderService.class); if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) { // The DownloaderService has started downloading the files, show progress initializeDownloadUI(); return; } // otherwise, download not needed so we fall through to the app } catch (PackageManager.NameNotFoundException e) { Log.e("EXPANSION ERROR", "Cannot find package!", e); } } else { validateXAPKZipFiles(); } btnBuiltIn = (Button) findViewById(R.id.button_builtin); btnMuscleIsolation = (Button) findViewById(R.id.button_muscle); btnCustomProgram = (Button) findViewById(R.id.button_custom); btnSportsTraining = (Button) findViewById(R.id.button_sports); btnhealthyLiving = (Button) findViewById(R.id.button_healthy); btnPersonalTrainer = (Button) findViewById(R.id.button_personal); btnVideos = (Button) findViewById(R.id.button_exercise_videos); btnCardio = (Button) findViewById(R.id.button_visit); btnImages = (Button) findViewById(R.id.button_exercise_photos); frameLayout = (FrameLayout) findViewById(R.id.frame); videoView = (VideoView) findViewById(R.id.video_view); btnBuiltIn.setOnClickListener(this); btnMuscleIsolation.setOnClickListener(this); btnCustomProgram.setOnClickListener(this); btnSportsTraining.setOnClickListener(this); btnhealthyLiving.setOnClickListener(this); btnPersonalTrainer.setOnClickListener(this); btnVideos.setOnClickListener(this); btnCardio.setOnClickListener(this); btnImages.setOnClickListener(this); mediaController = new MediaController(MainActivity.this); checkPermission(); }
From source file:com.dzt.musicplay.player.AudioService.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void showNotification() { Constant.print_i("AudioService----------->showNotification"); try {/*from ww w. j a v a 2 s . c o m*/ Media media = getCurrentMedia(); if (media == null) return; Bitmap cover = AudioUtil.getCover(this, media, 64); String title = media.getTitle(); String artist = media.getArtist(); String album = media.getAlbum(); Notification notification; // add notification to status bar NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.icon_music).setTicker(title + " - " + artist).setAutoCancel(false) .setOngoing(true); //Activity Intent notificationIntent = new Intent(this, MusicPlayActivity.class); notificationIntent.setAction(MusicPlayActivity.ACTION_SHOW_PLAYER); notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); notificationIntent.putExtra(START_FROM_NOTIFICATION, true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); if (LibVlcUtil.isJellyBeanOrLater()) { Intent iBackward = new Intent(ACTION_REMOTE_BACKWARD); Intent iPlay = new Intent(ACTION_REMOTE_PLAYPAUSE); Intent iForward = new Intent(ACTION_REMOTE_FORWARD); Intent iStop = new Intent(ACTION_REMOTE_STOP); PendingIntent piBackward = PendingIntent.getBroadcast(this, 0, iBackward, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piPlay = PendingIntent.getBroadcast(this, 0, iPlay, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piForward = PendingIntent.getBroadcast(this, 0, iForward, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piStop = PendingIntent.getBroadcast(this, 0, iStop, PendingIntent.FLAG_UPDATE_CURRENT); RemoteViews view = new RemoteViews(getPackageName(), R.layout.notification); if (cover != null) view.setImageViewBitmap(R.id.cover, cover); view.setTextViewText(R.id.songName, title); view.setTextViewText(R.id.artist, artist); view.setImageViewResource(R.id.play_pause, mLibVLC.isPlaying() ? R.drawable.ic_pause_w : R.drawable.ic_play_w); view.setOnClickPendingIntent(R.id.play_pause, piPlay); view.setOnClickPendingIntent(R.id.forward, piForward); view.setOnClickPendingIntent(R.id.stop, piStop); view.setOnClickPendingIntent(R.id.content, pendingIntent); RemoteViews view_expanded = new RemoteViews(getPackageName(), R.layout.notification_expanded); if (cover != null) view_expanded.setImageViewBitmap(R.id.cover, cover); view_expanded.setTextViewText(R.id.songName, title); view_expanded.setTextViewText(R.id.artist, artist); view_expanded.setTextViewText(R.id.album, album); view_expanded.setImageViewResource(R.id.play_pause, mLibVLC.isPlaying() ? R.drawable.ic_pause_w : R.drawable.ic_play_w); view_expanded.setOnClickPendingIntent(R.id.backward, piBackward); view_expanded.setOnClickPendingIntent(R.id.play_pause, piPlay); view_expanded.setOnClickPendingIntent(R.id.forward, piForward); view_expanded.setOnClickPendingIntent(R.id.stop, piStop); view_expanded.setOnClickPendingIntent(R.id.content, pendingIntent); notification = builder.build(); notification.contentView = view; notification.bigContentView = view_expanded; } else { builder.setLargeIcon(cover).setContentTitle(title) .setContentText(LibVlcUtil.isJellyBeanOrLater() ? artist : media.getSubtitle()) .setContentInfo(album).setContentIntent(pendingIntent); notification = builder.build(); } startService(new Intent(this, AudioService.class)); startForeground(3, notification); } catch (NoSuchMethodError e) { // Compat library is wrong on 3.2 // http://code.google.com/p/android/issues/detail?id=36359 // http://code.google.com/p/android/issues/detail?id=36502 } Constant.print_i("AudioService----------->showNotification----end"); }
From source file:com.fvd.nimbus.PaintActivity.java
void setCustomBackground(DrawView v) { Intent fileChooserIntent = new Intent(); fileChooserIntent.addCategory(Intent.CATEGORY_OPENABLE); fileChooserIntent.setType("image/*"); fileChooserIntent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(fileChooserIntent, "Select Picture"), 1); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); }
From source file:com.hdu.tx.aschool.ui.activity.ChatActivity.java
/** * /*from w ww .ja v a 2 s . co m*/ */ private void selectFileFromLocal() { Intent intent = null; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); } else { intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } startActivityForResult(intent, REQUEST_CODE_SELECT_FILE); }
From source file:com.fvd.nimbus.PaintActivity.java
public void getPicture() { try {/*w w w.ja v a 2s . co m*/ showProgress(true); Intent fileChooserIntent = new Intent(); fileChooserIntent.addCategory(Intent.CATEGORY_OPENABLE); fileChooserIntent.setType("image/*"); fileChooserIntent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(fileChooserIntent, "Select Picture"), TAKE_PICTURE); } catch (Exception e) { appSettings.appendLog("main:onClick " + e.getMessage()); showProgress(false); } }
From source file:com.apptentive.android.sdk.module.messagecenter.view.MessageCenterActivityContent.java
@Override public void onAttachImage() { try {// w w w. j a v a2 s. c om if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {//prior Api level 19 Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); Intent chooserIntent = Intent.createChooser(intent, null); viewActivity.startActivityForResult(chooserIntent, Constants.REQUEST_CODE_PHOTO_FROM_SYSTEM_PICKER); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); Intent chooserIntent = Intent.createChooser(intent, null); viewActivity.startActivityForResult(chooserIntent, Constants.REQUEST_CODE_PHOTO_FROM_SYSTEM_PICKER); } imagePickerLaunched = true; } catch (Exception e) { e.printStackTrace(); imagePickerLaunched = false; Log.d("can't launch image picker"); } }
From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.MessageCenterFragment.java
@Override public void onAttachImage() { try {//from w w w . ja v a 2 s .c o m if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {//prior Api level 19 Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); Intent chooserIntent = Intent.createChooser(intent, null); startActivityForResult(chooserIntent, Constants.REQUEST_CODE_PHOTO_FROM_SYSTEM_PICKER); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); Intent chooserIntent = Intent.createChooser(intent, null); startActivityForResult(chooserIntent, Constants.REQUEST_CODE_PHOTO_FROM_SYSTEM_PICKER); } imagePickerStillOpen = true; } catch (Exception e) { e.printStackTrace(); imagePickerStillOpen = false; ApptentiveLog.d("can't launch image picker"); } }