List of usage examples for android.content Intent getCategories
public Set<String> getCategories()
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 {/*from ww w . j a v a2 s . co m*/ 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.dycody.android.idealnote.ListFragment.java
/** * Notes list adapter initialization and association to view *//* w w w. ja v a2 s . c om*/ void initNotesList(Intent intent) { Log.d(Constants.TAG, "initNotesList intent: " + intent.getAction()); progress_wheel.setAlpha(1); list.setAlpha(0); // Search for a tag // A workaround to simplify it's to simulate normal search if (Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getCategories() != null && intent.getCategories().contains(Intent.CATEGORY_BROWSABLE)) { searchTags = intent.getDataString().replace(UrlCompleter.HASHTAG_SCHEME, ""); goBackOnToggleSearchLabel = true; } // Searching searchQuery = searchQueryInstant; searchQueryInstant = null; if (searchTags != null || searchQuery != null || Intent.ACTION_SEARCH.equals(intent.getAction())) { // Using tags if (searchTags != null && intent.getStringExtra(SearchManager.QUERY) == null) { searchQuery = searchTags; NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getNotesByTag", searchQuery); } else { // Get the intent, verify the action and get the query if (intent.getStringExtra(SearchManager.QUERY) != null) { searchQuery = intent.getStringExtra(SearchManager.QUERY); searchTags = null; } NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getNotesByPattern", searchQuery); } toggleSearchLabel(true); } else { // Check if is launched from a widget with categories if ((Constants.ACTION_WIDGET_SHOW_LIST.equals(intent.getAction()) && intent.hasExtra(Constants.INTENT_WIDGET)) || !TextUtils.isEmpty(mainActivity.navigationTmp)) { String widgetId = intent.hasExtra(Constants.INTENT_WIDGET) ? intent.getExtras().get(Constants.INTENT_WIDGET).toString() : null; if (widgetId != null) { String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, ""); String categoryId = TextHelper.checkIntentCategory(sqlCondition); mainActivity.navigationTmp = !TextUtils.isEmpty(categoryId) ? categoryId : null; } intent.removeExtra(Constants.INTENT_WIDGET); if (mainActivity.navigationTmp != null) { Long categoryId = Long.parseLong(mainActivity.navigationTmp); NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getNotesByCategory", categoryId); } else { NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getAllNotes", true); } } else { NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getAllNotes", true); } } }
From source file:de.azapps.mirakel.main_activity.MainActivity.java
private void handleIntent(final Intent intent) { if ((intent == null) || (intent.getAction() == null)) { Log.d(MainActivity.TAG, "action null"); } else if (DefinitionsHelper.SHOW_TASK.equals(intent.getAction()) || DefinitionsHelper.SHOW_TASK_REMINDER.equals(intent.getAction()) || DefinitionsHelper.SHOW_TASK_FROM_WIDGET.equals(intent.getAction())) { final Optional<Task> task = TaskHelper.getTaskFromIntent(intent); if (task.isPresent()) { this.currentList = task.get().getList(); if (this.mDrawerLayout != null) { this.mDrawerLayout.postDelayed(new Runnable() { @Override//from www.jav a 2s. co m public void run() { setCurrentTask(task.get(), true); } }, 10L); } } else { Log.d(MainActivity.TAG, "task null"); } if (intent.getAction().equals(DefinitionsHelper.SHOW_TASK_FROM_WIDGET)) { this.closeOnBack = true; } } else if (intent.getAction().equals(Intent.ACTION_SEND) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) { this.closeOnBack = true; this.newTaskContent = intent.getStringExtra(Intent.EXTRA_TEXT); this.newTaskSubject = intent.getStringExtra(Intent.EXTRA_SUBJECT); // If from google now, the content is the subject if ((intent.getCategories() != null) && intent.getCategories().contains("com.google.android.voicesearch.SELF_NOTE") && !this.newTaskContent.isEmpty()) { this.newTaskSubject = this.newTaskContent; this.newTaskContent = ""; } if (!"text/plain".equals(intent.getType()) && (this.newTaskSubject == null)) { this.newTaskSubject = MirakelCommonPreferences.getImportFileTitle(); } final Optional<ListMirakel> listFromSharing = MirakelModelPreferences.getImportDefaultList(); if (listFromSharing.isPresent()) { addTaskFromSharing(listFromSharing.get(), intent); } else { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.import_to); final List<CharSequence> items = new ArrayList<>(); final List<Long> list_ids = new ArrayList<>(); final int currentItem = 0; for (final ListMirakel list : ListMirakel.all()) { if (list.getId() > 0) { items.add(list.getName()); list_ids.add(list.getId()); } } builder.setSingleChoiceItems(items.toArray(new CharSequence[items.size()]), currentItem, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { final Optional<ListMirakel> listMirakelOptional = ListMirakel .get(list_ids.get(which)); withOptional(listMirakelOptional, new OptionalUtils.Procedure<ListMirakel>() { @Override public void apply(final ListMirakel input) { addTaskFromSharing(input, intent); dialog.dismiss(); } }); } }); builder.create().show(); } } else if (intent.getAction().equals(DefinitionsHelper.SHOW_LIST) || intent.getAction().contains(DefinitionsHelper.SHOW_LIST_FROM_WIDGET)) { final Optional<ListMirakel> listMirakelOptional = ListHelper.getListMirakelFromIntent(intent); if (listMirakelOptional.isPresent()) { final ListMirakel list = listMirakelOptional.get(); setCurrentList(list); final Optional<Task> taskOptional = list.getFirstTask(); if (taskOptional.isPresent()) { this.currentTask = taskOptional.get(); } if (getTaskFragment() != null) { getTaskFragment().update(this.currentTask); } } else { Log.d(TAG, "show_list does not pass list, so ignore this"); } } else if (intent.getAction().equals(DefinitionsHelper.SHOW_LISTS)) { this.mDrawerLayout.openDrawer(DefinitionsHelper.GRAVITY_LEFT); } else if (intent.getAction().equals(Intent.ACTION_SEARCH)) { final String query = intent.getStringExtra(SearchManager.QUERY); search(query); } else if (intent.getAction().contains(DefinitionsHelper.ADD_TASK_FROM_WIDGET)) { final int listId = Integer .parseInt(intent.getAction().replace(DefinitionsHelper.ADD_TASK_FROM_WIDGET, "")); final Optional<ListMirakel> listMirakelOptional = ListMirakel.get(listId); if (listMirakelOptional.isPresent()) { setCurrentList(listMirakelOptional.get()); } else { setCurrentList(ListMirakel.safeFirst()); } this.mDrawerLayout.postDelayed(new Runnable() { @Override public void run() { if ((getTasksFragment() != null) && getTasksFragment().isReady()) { getTasksFragment().focusNew(true); } else if (!MirakelCommonPreferences.isTablet()) { runOnUiThread(new Runnable() { @Override public void run() { if (getTasksFragment() != null) { getTasksFragment().focusNew(true); } else { Log.wtf(MainActivity.TAG, "Tasksfragment null"); } } }); } } }, 10); } else if (intent.getAction().equals(DefinitionsHelper.SHOW_MESSAGE)) { final String message = intent.getStringExtra(Intent.EXTRA_TEXT); String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT); if (message != null) { if (subject == null) { subject = getString(R.string.message_notification); } final TextView msg = (TextView) getLayoutInflater().inflate(R.layout.alertdialog_textview, null); msg.setText(Html.fromHtml(message)); msg.setMovementMethod(LinkMovementMethod.getInstance()); msg.setClickable(true); new AlertDialog.Builder(this).setTitle(subject).setView(msg).show(); } } else { setCurrentItem(getTaskFragmentPosition()); } if (((intent == null) || (intent.getAction() == null) || !intent.getAction().contains(DefinitionsHelper.ADD_TASK_FROM_WIDGET)) && (getTasksFragment() != null)) { getTasksFragment().clearFocus(); } setIntent(null); if (this.currentList == null) { setCurrentList(SpecialList.firstSpecialSafe()); } }
From source file:org.planetmono.dcuploader.ActivityUploader.java
@SuppressWarnings("unchecked") @Override//w ww . j a va 2 s .co m public void onCreate(Bundle savedState) { super.onCreate(savedState); initViews(); if (formLocation) queryLocation(true); if (savedState != null) { if (savedState.containsKey("tempfile")) tempFile = new File(savedState.getString("tempfile")); if (savedState.containsKey("target")) resolveTarget(savedState.getString("target")); if (savedState.containsKey("tempfiles")) tempFiles = savedState.getStringArrayList("tempfiles"); if (savedState.containsKey("contents")) { contents = new ArrayList<Uri>(); String[] carr = savedState.getStringArray("contents"); for (String s : carr) contents.add(Uri.parse(s)); } } postfix = "from <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; Button uploadVisit = (Button) findViewById(R.id.upload_visit); if (passThrough || target == null) uploadVisit.setEnabled(false); else uploadVisit.setEnabled(true); /* populate data by getting STREAM parameter */ Intent i = getIntent(); Bundle b = i.getExtras(); String action = i.getAction(); if (action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_SEND_MULTIPLE)) { called = true; if (i.hasExtra(Intent.EXTRA_STREAM)) { Object o = b.get(Intent.EXTRA_STREAM); /* quick and dirty. any better idea? */ try { contents.add((Uri) o); } catch (Exception e1) { try { contents = (ArrayList<Uri>) ((ArrayList<Uri>) o).clone(); } catch (Exception e2) { } } boolean exceeded = false; if (contents.size() > 5) { exceeded = true; do { contents.remove(5); } while (contents.size() > 5); } galleryChanged = true; updateImageButtons(); resetThumbnails(); updateGallery(); if (exceeded) Toast.makeText(this, " 5 . 5 ??? ? ?.", Toast.LENGTH_LONG).show(); } if (i.hasExtra(Intent.EXTRA_TEXT)) { ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TEXT)); } } else if (action.equals("share")) { called = true; /* HTC web browser uses non-standard intent */ ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TITLE)); } else if (action.equals(Intent.ACTION_VIEW)) { Uri uri = i.getData(); if (i.getCategories().contains(Intent.CATEGORY_BROWSABLE)) { passThrough = true; Pattern p = Pattern.compile("id=([\\-a-zA-Z0-9_]+)"); Matcher m = p.matcher(uri.toString()); if (m.find()) { resolveTarget(m.group(1)); } else { passThrough = false; } if (uri.getHost().equals(Application.HOST_DCMYS)) { destination = Application.DESTINATION_DCMYS; postfix = "from dc.m.dcmys.kr w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; } else if (uri.getHost().equals(Application.HOST_MOOLZO)) { destination = Application.DESTINATION_MOOLZO; postfix = "- From m.oolzo.com w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>"; } else if (uri.getHost().equals(Application.HOST_DCINSIDE)) { destination = Application.DESTINATION_DCINSIDE; } setDefaultImage(); } } reloadConfigurations(); }
From source file:com.ubikod.capptain.android.sdk.reach.CapptainReachAgent.java
/** * Try to notify the content to the user. * @param content reach content./*from w ww . ja v a 2 s. c om*/ * @param replaySystemNotifications true iff system notifications must be replayed. * @throws RuntimeException if an error occurs. */ private void notifyContent(final CapptainReachContent content, boolean replaySystemNotifications) throws RuntimeException { /* Check expiry */ final long localId = content.getLocalId(); if (content.hasExpired()) { /* Delete */ deleteContent(content); return; } /* If datapush, just broadcast, can be done in parallel with another content */ final Intent intent = content.getIntent(); if (content instanceof CapptainDataPush) { /* If it's a datapush it may already be in the process of broadcasting. */ if (!mPendingDataPushes.add(localId)) return; /* Broadcast intent */ final CapptainDataPush dataPush = (CapptainDataPush) content; intent.setPackage(mContext.getPackageName()); mContext.sendOrderedBroadcast(intent, null, new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { /* The last broadcast receiver to set a defined result wins (to determine which result). */ switch (getResultCode()) { case RESULT_OK: dataPush.actionContent(context); break; case RESULT_CANCELED: dataPush.exitContent(context); break; default: dataPush.dropContent(context); } /* Clean broadcast state */ mPendingDataPushes.remove(localId); } }, null, RESULT_UNDEFINED, null, null); /* Datapush processed */ return; } /* Don't notify in-app if we are already notifying in app or showing a content */ if (mState != State.IDLE && !content.isSystemNotification()) return; /* Don't process again a pending notification */ if (mPendingNotifications.contains(localId)) return; /* Not an interactive content, exit (but there is no other type left, this is just a cast guard) */ if (!(content instanceof CapptainReachInteractiveContent)) return; CapptainReachInteractiveContent iContent = (CapptainReachInteractiveContent) content; /* Don't replay system notification unless told otherwise. */ if (!replaySystemNotifications && iContent.isSystemNotification() && iContent.getNotificationLastDisplayedDate() != null && iContent.getNotificationLastDisplayedDate() > mAppLastUpdateTime) return; /* Check if the content can be notified in the current context (behavior) */ if (!iContent.canNotify(sActivityManager.getCurrentActivityAlias())) return; /* If there is a show intent */ if (intent != null) { /* Filter intent for the target package name */ filterIntent(intent); /* If the intent could not be resolved */ if (intent.getComponent() == null) { /* If there was no category */ if (intent.getCategories() == null) /* Notification cannot be done */ throw new ActivityNotFoundException(); /* Remove categories */ Collection<String> categories = new HashSet<String>(intent.getCategories()); for (String category : categories) intent.removeCategory(category); /* Try filtering again */ filterIntent(intent); /* Notification cannot be done, skip content */ if (intent.getComponent() == null) throw new ActivityNotFoundException(); } } /* Delegate notification */ Boolean notifierResult = getNotifier(content).handleNotification(iContent); /* Check if notifier rejected content notification for now */ if (Boolean.FALSE.equals(notifierResult)) /* The notifier rejected the content, nothing more to do */ return; /* Cache content if accepted, it will most likely be used again soon for the next steps. */ mContentCache.put(localId, content); /* * If notifier did not return null (e.g. returned true, meaning actually accepted the content), * we assume the notification is correctly displayed. */ if (Boolean.TRUE.equals(notifierResult)) { /* Report displayed feedback */ iContent.displayNotification(mContext); /* Track in-app content life cycle: one at a time */ if (!iContent.isSystemNotification()) mState = State.NOTIFYING_IN_APP; } /* Track pending notifications to avoid re-processing them every time we change activity. */ if (notifierResult == null) mPendingNotifications.add(localId); }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
@Override public void onNewIntent(Intent i) { intent = i;/*ww w . j av a 2 s .c o m*/ path = i.getStringExtra("path"); if (path != null) { if (new File(path).isDirectory()) { Fragment f = getDFragment(); if ((f.getClass().getName().contains("TabFragment"))) { MainFragment m = ((MainFragment) getFragment().getTab()); m.loadlist(path, false, OpenMode.FILE); } else goToMain(path); } else utils.openFile(new File(path), mainActivity); } else if (i.getStringArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS) != null) { ArrayList<BaseFile> failedOps = i.getParcelableArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS); if (failedOps != null) { mainActivityHelper.showFailedOperationDialog(failedOps, i.getBooleanExtra("move", false), this); } } else if (i.getCategories() != null && i.getCategories().contains(CLOUD_AUTHENTICATOR_GDRIVE)) { // we used an external authenticator instead of APIs. Probably for Google Drive CloudRail.setAuthenticationResponse(intent); } else if ((openProcesses = i.getBooleanExtra(KEY_INTENT_PROCESS_VIEWER, false))) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content_frame, new ProcessViewer(), KEY_INTENT_PROCESS_VIEWER); // transaction.addToBackStack(null); selectedStorage = SELECT_102; openProcesses = false; //title.setText(utils.getString(con, R.string.process_viewer)); //Commit the transaction transaction.commitAllowingStateLoss(); supportInvalidateOptionsMenu(); } else if (intent.getAction() != null) { if (intent.getAction().equals(Intent.ACTION_GET_CONTENT)) { // file picker intent mReturnIntent = true; Toast.makeText(this, getString(R.string.pick_a_file), Toast.LENGTH_LONG).show(); } else if (intent.getAction().equals(RingtoneManager.ACTION_RINGTONE_PICKER)) { // ringtone picker intent mReturnIntent = true; mRingtonePickerIntent = true; Toast.makeText(this, getString(R.string.pick_a_file), Toast.LENGTH_LONG).show(); } else if (intent.getAction().equals(Intent.ACTION_VIEW)) { // zip viewer intent Uri uri = intent.getData(); zippath = uri.toString(); openZip(zippath); } if (SDK_INT >= Build.VERSION_CODES.KITKAT) { if (intent.getAction().equals(UsbManager.ACTION_USB_DEVICE_ATTACHED)) { if (sharedPref.getString(KEY_PREF_OTG, null) == null) { sharedPref.edit().putString(KEY_PREF_OTG, VALUE_PREF_OTG_NULL).apply(); refreshDrawer(); } } else if (intent.getAction().equals(UsbManager.ACTION_USB_DEVICE_DETACHED)) { sharedPref.edit().putString(KEY_PREF_OTG, null).apply(); refreshDrawer(); } } } }