List of usage examples for android.content Intent setClassName
public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className)
From source file:de.baumann.browser.helper.Activity_intent.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); onNewIntent(getIntent());/*from w w w. j a v a2 s .c o m*/ android.content.Intent intent = getIntent(); Uri data = intent.getData(); String domain; if (Uri.parse(data.toString()).getHost().length() == 0) { domain = getString(R.string.app_domain); } else { domain = Uri.parse(data.toString()).getHost(); } if (domain.contains("www.")) { domain = domain.replace("www.", "").toUpperCase(); } String domain2 = domain.substring(0, 1).toUpperCase() + domain.substring(1); PreferenceManager.setDefaultValues(this, R.xml.user_settings, false); PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); sharedPref.edit().putString("add_readLater_link", data.toString()).apply(); sharedPref.edit().putString("add_readLater_domain", domain2).apply(); Random rand = new Random(); int n = rand.nextInt(100000); android.content.Intent iMain = new android.content.Intent(); iMain.setData(data); iMain.setAction(Intent.ACTION_VIEW); iMain.setClassName(Activity_intent.this, "de.baumann.browser.Browser_left"); android.content.Intent iAction = new android.content.Intent(this, Browser_left.class); iAction.setAction("readLater"); android.content.Intent iAction_2 = new android.content.Intent(this, Activity_intent_add.class); iAction_2.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); PendingIntent piMain = PendingIntent.getActivity(this, n, iMain, 0); PendingIntent piAction = PendingIntent.getActivity(this, n, iAction, 0); PendingIntent piAction_2 = PendingIntent.getActivity(this, n, iAction_2, 0); NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.format_list_bulleted, getString(R.string.readLater_action), piAction).build(); NotificationCompat.Action action_2 = new NotificationCompat.Action.Builder(R.drawable.format_list_bulleted, getString(R.string.readLater_action2), piAction_2).build(); android.support.v4.app.NotificationCompat.Builder builderSummary = new android.support.v4.app.NotificationCompat.Builder( Activity_intent.this).setAutoCancel(true).setSmallIcon(R.drawable.earth) .setColor(ContextCompat.getColor(Activity_intent.this, R.color.colorPrimary)) .setGroup("Browser").setGroupSummary(true).setContentIntent(piMain); Notification notification = new android.support.v4.app.NotificationCompat.Builder(Activity_intent.this) .setColor(ContextCompat.getColor(Activity_intent.this, R.color.colorPrimary)) .setSmallIcon(R.drawable.earth).setContentTitle(getString(R.string.readLater_title)) .setContentText(data.toString()).setContentIntent(piMain).setAutoCancel(true).setGroup("Browser") .addAction(action).addAction(action_2) .setStyle(new android.support.v4.app.NotificationCompat.BigTextStyle().bigText(data.toString())) .setPriority(Notification.PRIORITY_MAX).setVibrate(new long[0]).build(); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(n, notification); notificationManager.notify(0, builderSummary.build()); finish(); }
From source file:com.omniwearhaptics.api.OmniWearHelper.java
public OmniWearHelper(final Context context, OnOmniWearEventListener eventListener, OnOmniWearLogListener logListener) { mParent = context;//from www. java2 s . co m mOnOmniWearEventListener = eventListener; mOnOmniWearLogListener = logListener; Intent intent = new Intent(); intent.setClassName("com.omniwearhaptics.omniwearbtbridge", "com.omniwearhaptics.omniwearbtbridge.OmniWearService"); permissionsCheck(); // Connect to the OmniWear service. mServiceConnection = new ServiceConnection() { // When the service is bound, try to connect to the device. public void onServiceConnected(ComponentName name, IBinder service) { // Create the interface. mOmniWearInterface = IOmniWear.Stub.asInterface(service); // Register the callback. if (mCallback != null) { try { if (mOmniWearInterface != null) { mOmniWearInterface.registerCallback(mCallback); mCallback.onOmniWearEvent(EVENT_SERVICE_BOUND); } } catch (RemoteException e) { e.printStackTrace(); } } else { Log.w(TAG, "mCallback is null in searchForOmniWearDevice"); } } public void onServiceDisconnected(ComponentName name) { try { mOmniWearInterface.unregisterCallback(); } catch (RemoteException e) { e.printStackTrace(); } } }; context.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE); }
From source file:liqui.droid.activity.Test.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { // Uri ISSUES_URI = DBProvider.ISSUE_PURE_CONTENT_URI.buildUpon().appendQueryParameter("db", getAPIDB()).build(); /*/* w ww .j av a 2 s .co m*/ Cursor c = getContentResolver().query(ISSUES_URI, null, null, null, null); c.moveToFirst(); while (!c.isAfterLast()) { String issueId = c.getString(c.getColumnIndex(DB.Issue.COLUMN_ID)); Long issueCreated = c.getLong(c.getColumnIndex(DB.Issue.COLUMN_CREATED)); String issueArea = c.getString(c.getColumnIndex(DB.Issue.COLUMN_AREA_ID)); PrettyTime pt = new PrettyTime(); Log.d("XXXXXX", "id " + issueId + " areaId " + issueArea + " created " + pt.format(new DateTime(issueCreated).toDate())); // http://stackoverflow.com/questions/5564530 ContentValues event = new ContentValues(); event.put("calendar_id", id); event.put("title", "Created issue " + issueId + " area " + issueArea); event.put("dtstart", issueCreated); event.put("dtend", issueCreated + 60 * 5 * 1000); event.put("allDay", 0); // 0 for false, 1 for true event.put("eventStatus", 1); event.put("visibility", 3); // public event.put("hasAlarm", 1); // 0 for false, 1 for true event.put("eventTimezone", TimeZone.getDefault().getID()); Uri url = getContentResolver().insert(EVENTS_URI, event); c.moveToNext(); } c.close(); */ /* Intent calendarIntent = new Intent() ; calendarIntent.setClassName("com.android.calendar","com.android.calendar.AgendaActivity"); startActivity(calendarIntent); */ Intent calDetailsIntent = new Intent(); calDetailsIntent.setClassName("liqui.droid", "liqui.droid.CalendarEventsActivity"); Bundle extras = new Bundle(); extras.putString("_id", String.valueOf(id)); calDetailsIntent.putExtras(extras); startActivity(calDetailsIntent); }
From source file:android.security.cts.BrowserTest.java
/** * Create intents for all activities that can display the given URI. *///from ww w . j a va2 s . c om private List<Intent> createAllIntents(Uri uri) { Intent implicit = new Intent(Intent.ACTION_VIEW); implicit.setData(uri); /* convert our implicit Intent into multiple explicit Intents */ List<Intent> retval = new ArrayList<Intent>(); PackageManager pm = mContext.getPackageManager(); List<ResolveInfo> list = pm.queryIntentActivities(implicit, PackageManager.GET_META_DATA); for (ResolveInfo i : list) { Intent explicit = new Intent(Intent.ACTION_VIEW); explicit.setClassName(i.activityInfo.packageName, i.activityInfo.name); explicit.setData(uri); explicit.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); retval.add(explicit); } return retval; }
From source file:com.altcanvas.twitspeak.TwitSpeakActivity.java
public void continueOnCreate() { G.init(this); db = new Database(this); twitBox = (TextView) findViewById(R.id.twitbox); settingsIcon = (ImageView) findViewById(R.id.settings); twitBox.setText("Loading"); twitBox.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { speakTwit();//from w ww. j av a 2 s. co m } }); settingsIcon.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent iSettings = new Intent(); iSettings.setClassName("com.altcanvas.twitspeak", SettingsActivity.class.getName()); TwitSpeakActivity.this.startActivity(iSettings); } }); Intent checkIntent = new Intent(); checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA); startActivityForResult(checkIntent, G.REQCODE_CHECK_TTS); }
From source file:com.mifos.mifosxdroid.activity.pathtracking.PathTrackingActivity.java
@Override public void onItemClick(View childView, int position) { List<UserLatLng> userLatLngs = pathTrackingAdapter.getLatLngList(userLocations.get(position).getLatlng()); String uri = "http://maps.google.com/maps?f=d&hl=en&saddr=" + userLatLngs.get(0).getLat() + "," + userLatLngs.get(0).getLng() + "&daddr=" + userLatLngs.get(userLatLngs.size() - 1).getLat() + "," + "" + userLatLngs.get(userLatLngs.size() - 1).getLng(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(Intent.createChooser(intent, getString(R.string.start_tracking))); }
From source file:de.baumann.hhsmoodle.popup.Popup_todo_restart.java
private void setTodoList() { NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nMgr.cancelAll();//from w w w. j ava 2 s . c om Schedule_helper.setAlarm(Popup_todo_restart.this); Intent serviceIntent = new Intent(Popup_todo_restart.this, class_AlarmService.class); startService(serviceIntent); //display data final int layoutstyle = R.layout.list_item_notes; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "todo_title", "todo_content", "todo_creation" }; final Cursor row = db.fetchAllData(Popup_todo_restart.this); SimpleCursorAdapter adapter = new SimpleCursorAdapter(Popup_todo_restart.this, layoutstyle, row, column, xml_id, 0) { @Override public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title")); final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content")); final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment")); View v = super.getView(position, convertView, parent); ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); switch (todo_attachment) { case "true": iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.alert_circle); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.alert_circle_red); int n = Integer.valueOf(_id); android.content.Intent iMain = new android.content.Intent(); iMain.setAction("shortcutToDo"); iMain.setClassName(Popup_todo_restart.this, "de.baumann.hhsmoodle.activities.Activity_splash"); PendingIntent piMain = PendingIntent.getActivity(Popup_todo_restart.this, n, iMain, 0); NotificationCompat.Builder builderSummary = new NotificationCompat.Builder( Popup_todo_restart.this).setSmallIcon(R.drawable.school) .setColor(ContextCompat.getColor(Popup_todo_restart.this, R.color.colorPrimary)) .setGroup("HHS_Moodle").setGroupSummary(true).setContentIntent(piMain); Notification notification = new NotificationCompat.Builder(Popup_todo_restart.this) .setColor(ContextCompat.getColor(Popup_todo_restart.this, R.color.colorPrimary)) .setSmallIcon(R.drawable.school).setContentTitle(todo_title) .setContentText(todo_content).setContentIntent(piMain).setAutoCancel(true) .setGroup("HHS_Moodle") .setStyle(new NotificationCompat.BigTextStyle().bigText(todo_content)) .setPriority(Notification.PRIORITY_DEFAULT).setVibrate(new long[0]).build(); NotificationManager notificationManager = (NotificationManager) Popup_todo_restart.this .getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(n, notification); notificationManager.notify(0, builderSummary.build()); break; } return v; } }; lv.setAdapter(adapter); //onClick function try { helper_security.encrypt(Popup_todo_restart.this, "/databases/todo_DB_v01.db", "/databases/todo_DB_v01_en.db"); } catch (Exception e) { e.printStackTrace(); } new Handler().postDelayed(new Runnable() { public void run() { finish(); } }, 1000); }
From source file:org.kontalk.ui.MainActivity.java
private boolean ifHuaweiAlert() { boolean skipMessage = Preferences.isSkipHuaweiProtectedApps(); if (!skipMessage) { Intent intent = new Intent(); intent.setClassName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"); if (SystemUtils.isCallable(this, intent)) { new CheckboxAlertDialog.Builder(this).checkboxText(R.string.check_do_not_show_again) .onCheckboxChanged(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Preferences.setSkipHuaweiProtectedApps(isChecked); }//from w w w.ja va 2s .c o m }).title(R.string.title_huawei_protected_apps).content(R.string.msg_huawei_protected_apps) .positiveText(R.string.btn_huawei_protected_apps).negativeText(android.R.string.cancel) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { startHuaweiProtectedApps(); } }).show(); return true; } else { Preferences.setSkipHuaweiProtectedApps(true); } } return false; }
From source file:com.todoroo.astrid.helper.SyncActionHelper.java
public void performSyncAction() { List<SyncV2Provider> activeV2Providers = syncService.activeProviders(); int activeSyncs = syncActions.size() + activeV2Providers.size(); if (activeSyncs == 0) { String desiredCategory = activity.getString(R.string.SyP_label); // Get a list of all sync plugins and bring user to the prefs pane // for one of them Intent queryIntent = new Intent(AstridApiConstants.ACTION_SETTINGS); PackageManager pm = activity.getPackageManager(); List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(queryIntent, PackageManager.GET_META_DATA); int length = resolveInfoList.size(); ArrayList<Intent> syncIntents = new ArrayList<Intent>(); // Loop through a list of all packages (including plugins, addons) // that have a settings action: filter to sync actions for (int i = 0; i < length; i++) { ResolveInfo resolveInfo = resolveInfoList.get(i); Intent intent = new Intent(AstridApiConstants.ACTION_SETTINGS); intent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name); String category = MetadataHelper.resolveActivityCategoryName(resolveInfo, pm); if (GtasksPreferences.class.getName().equals(resolveInfo.activityInfo.name)) continue; if (resolveInfo.activityInfo.metaData != null) { Bundle metadata = resolveInfo.activityInfo.metaData; if (!metadata.getBoolean("syncAction")) //$NON-NLS-1$ continue; }//from w ww. ja v a 2 s .c o m if (category.equals(desiredCategory)) { syncIntents.add(new IntentWithLabel(intent, resolveInfo.activityInfo.loadLabel(pm).toString())); } } final Intent[] actions = syncIntents.toArray(new Intent[syncIntents.size()]); DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface click, int which) { fragment.startActivityForResult(actions[which], TaskListFragment.ACTIVITY_SETTINGS); } }; if (actions.length == 1) { fragment.startActivityForResult(actions[0], TaskListFragment.ACTIVITY_SETTINGS); } else { showSyncOptionMenu(actions, listener); } } else { syncService.synchronizeActiveTasks(true, syncResultCallback); } }
From source file:com.josephblough.sbt.activities.ShortcutActivity.java
private void createLauncher(final int searchType, final String criteria) { Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setClassName(this, this.getClass().getName()); shortcutIntent.putExtra(SEARCH_TYPE, searchType); if (criteria != null) shortcutIntent.putExtra(CRITERIA, criteria); // Pass back the criteria from the activity // Set up the container intent (the response to the caller) Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, ITEMS[searchType]); Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, ICONS[searchType]); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); // Return the result to the launcher setResult(RESULT_OK, intent);// w ww .j av a2s .c om finish(); }