List of usage examples for android.content Intent setComponent
public @NonNull Intent setComponent(@Nullable ComponentName component)
From source file:com.kinoma.kinomaplay.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log.i("kinoma", "GcmBroadcastReceiver.onReceive:" + intent.getAction()); ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);/* w w w .j a v a2s . c om*/ }
From source file:com.google.developers.actions.debugger.CayleyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try {//from w w w .ja v a 2 s .co m getActionBar().setDisplayHomeAsUpEnabled(true); } catch (NullPointerException e) { e.printStackTrace(); } setContentView(R.layout.activity_cayley); Intent intent = getIntent(); intent.setAction(intent.getStringExtra(MainActivity.ACTION)); intent.setComponent(null); mIntent = intent; mActionType = intent.getStringExtra(MainActivity.ACTION_TYPE); if (mActionType.equals("PLAY_ARTIST")) { mEditText = (EditText) findViewById(R.id.artist); mEditText.setVisibility(View.VISIBLE); mEditText.setText(getString(R.string.dual_core)); } else { mEditText = (EditText) findViewById(R.id.genre); mEditText.setVisibility(View.VISIBLE); mEditText.setText(getString(R.string.nerdcore)); } }
From source file:org.addhen.birudo.receiver.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);/*from w ww .ja va 2s . c om*/ }
From source file:com.buddi.client.dfu.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f);// w ww . j a va 2 s . c o m mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); } mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); try { startActivity(action); } catch (final ActivityNotFoundException e) { Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show(); } mDrawerLayout.closeDrawers(); } }); // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); mDrawerLayout.closeDrawers(); } }); container.addView(item); } }
From source file:org.tecsos.pasos.comm.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);/* w w w .j a v a 2 s. c o m*/ }
From source file:com.moods_final.moods.entertainment.YouTubeAPIDemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.topics);// www.j ava2 s . com StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); lvTopics = (ListView) findViewById(R.id.topics); //AsyncTaskRunner runner = new AsyncTaskRunner(); //runner.execute(); try { lvTopics.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, this.getTopics())); } catch (IOException e) { e.printStackTrace(); } lvTopics.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int position, long id) { //Take action here. Log.e("pressed", ":" + topics.get(position).toString()); Intent intent = new Intent().putExtra("chId", topid.get(position).toString()); ; intent.setComponent(new ComponentName(getPackageName(), "com.moods_final.moods.entertainment.ChannelListActivity")); startActivity(intent); } }); }
From source file:org.alfresco.mobile.android.application.managers.ActionUtils.java
/** * Open Play Store application or its web version if no play store * available.//from ww w .j av a2s . co m * * @param c : Android Context */ public static void actionDisplayPlayStore(Context c) { // Retrieve list of application that understand market Intent Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?type=org.alfresco.mobile.android.application")); final PackageManager mgr = c.getPackageManager(); List<ResolveInfo> list = mgr.queryIntentActivities(intent, 0); // By default we redirect to the webbrowser version of play store. intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("https://play.google.com/")); for (ResolveInfo resolveInfo : list) { // If we find something related to android we open the application // version of play store. if (resolveInfo.activityInfo.applicationInfo.packageName.contains("android")) { intent.setComponent(new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName, resolveInfo.activityInfo.name)); intent.setData(Uri.parse("market://")); break; } } c.startActivity(intent); }
From source file:cz.vutbr.fit.stud.xslade12.lostphone.recievers.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Spustime wakefull service, ktera se postara o spracovani GCM message ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);/*w w w. ja v a 2 s.co m*/ }
From source file:com.example.RITW.proximity.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel //final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { // mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f);//from w w w .ja v a 2s .c o m // mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); } /*mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); try { startActivity(action); } catch (final ActivityNotFoundException e) { Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show(); } mDrawerLayout.closeDrawers(); } });*/ // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); mDrawerLayout.closeDrawers(); } }); container.addView(item); } }
From source file:de.azapps.mirakel.dashclock.MirakelExtension.java
@Override protected void onUpdateData(final int reason) { // Get values from Settings final Optional<ListMirakel> listMirakelOptional = SettingsHelper.getList(); if (!listMirakelOptional.isPresent()) { reportError(this, getString(R.string.list_not_found), getString(R.string.list_not_found_message)); return;/*from w w w . j av a 2 s .com*/ } final int maxTasks = SettingsHelper.getMaxTasks(); final ListMirakel listMirakel = listMirakelOptional.get(); final MirakelQueryBuilder mirakelQueryBuilder = listMirakel.getTasksQueryBuilder(); final Cursor cursor; try { cursor = mirakelQueryBuilder.query(Task.URI); } catch (final SecurityException ignored) { reportError(this, getString(R.string.no_permission_title), getString(R.string.no_permission)); return; } catch (final RuntimeException e) { reportError(this, getString(R.string.cannot_communicate), getString(R.string.unexpected_error)); Log.e(TAG, "Cannot communicate to Mirakel", e); return; } // Set Status if (cursor.getCount() == 0 && !SettingsHelper.showEmpty()) { Log.d(TAG, "hide"); publishUpdate(new ExtensionData().visible(false)); } else { final boolean showDue = SettingsHelper.showDue(); final SimpleDateFormat dateFormat = new SimpleDateFormat(getString(R.string.due_outformat), Locale.getDefault()); final String status = getResources().getQuantityString(R.plurals.status, cursor.getCount(), cursor.getCount()); final String tasks[] = new String[Math.min(maxTasks, cursor.getCount())]; int i = 0; while (cursor.moveToNext() && i < maxTasks) { final Task task = MirakelQueryBuilder.cursorToObject(cursor, Task.class); final Optional<Calendar> dueOptional = task.getDue(); final StringBuilder taskRow = new StringBuilder(); if (dueOptional.isPresent() && showDue) { taskRow.append(dateFormat.format(dueOptional.get().getTime())).append(": "); } taskRow.append(task.getName()); tasks[i] = taskRow.toString(); i++; } cursor.close(); // Add click-event final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent( new ComponentName("de.azapps.mirakelandroid", "de.azapps.mirakel.main_activity.MainActivity")); intent.setAction("de.azapps.mirakel.SHOW_LIST"); intent.putExtra("de.azapps.mirakel.EXTRA_LIST_ID", listMirakel.getId()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Set Content publishUpdate(new ExtensionData().visible(true).icon(R.drawable.ic_mirakel).status(status) .expandedBody(TextUtils.join("\n", tasks)).clickIntent(intent)); } }