List of usage examples for android.content ComponentName ComponentName
private ComponentName(String pkg, Parcel in)
From source file:com.lee.sdk.utils.Utils.java
/** * ????/* ww w . j a v a 2 s . c o m*/ * * @param activity ?Activity??? * @param nameId ???? * @param iconId ?? * @param appendFlags ????IntentFlag */ public static void addShortcut(Activity activity, int nameId, int iconId, int appendFlags) { Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); // ???? shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, activity.getString(nameId)); shortcut.putExtra("duplicate", false); // ???? // ?Activity??? ComponentName comp = new ComponentName(activity.getPackageName(), activity.getClass().getName()); Intent intent = new Intent(Intent.ACTION_MAIN).setComponent(comp); if (appendFlags != 0) { intent.addFlags(appendFlags); } shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); // ?? ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(activity, iconId); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes); activity.sendBroadcast(shortcut); }
From source file:com.mono.applink.Twitter.java
/** Called when the activity is first created. */ @Override/*from ww w . ja va2s . com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String url = getIntent().getData().toString(); if (url.contains("twitter.com") && !url.contains("status") && !url.contains("direct_messages") && !url.contains("user_spam_reports") && !url.contains("account") && !url.contains("settings"))//Just if it is a link of a user profile { new TwitterUser().execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Sorry, but this type of link is not currently supported"); builder.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setData(Uri.parse(url)); startActivity(i); finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:com.android.quicksearchbox.google.GoogleSuggestClient.java
@Override public ComponentName getIntentComponent() { return new ComponentName(getContext(), GoogleSearch.class); }
From source file:com.darshancomputing.BatteryIndicatorPro.AlarmsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); mInflater = inflater;// w w w . j av a2s . co m View view = mInflater.inflate(R.layout.alarms, container, false); mAlarmsList = (LinearLayout) view.findViewById(R.id.alarms_list); if (mCursor == null) { TextView addAlarmTv = (TextView) view.findViewById(R.id.add_alarm_tv); addAlarmTv.setText("Database error!"); return view; } view.findViewById(R.id.add_alarm).setOnClickListener(new OnClickListener() { public void onClick(View v) { int id = alarms.addAlarm(); if (id < 0) { Toast.makeText(getActivity(), "Error!", Toast.LENGTH_SHORT).show(); } ComponentName comp = new ComponentName(getActivity().getPackageName(), AlarmEditActivity.class.getName()); startActivity(new Intent().setComponent(comp).putExtra(AlarmEditActivity.EXTRA_ALARM_ID, id)); } }); return view; }
From source file:com.moods_final.moods.entertainment.YouTubeAPIDemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.topics);//w ww . ja v a 2 s . co m 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:com.androidzeitgeist.dashwatch.muzei.SourceManager.java
private SourceManager(Context context) { mApplicationContext = context.getApplicationContext(); mSubscriberComponentName = new ComponentName(context, SourceSubscriberService.class); mSharedPrefs = context.getSharedPreferences("muzei_art_sources", 0); loadStoredData();//from www . ja v a 2 s.com }
From source file:com.android.server.telecom.testapps.CallNotificationReceiver.java
/** * Creates and sends the intent to add an incoming call through Telecom. * * @param context The current context./* www . j a va2s . c o m*/ * @param isVideoCall {@code True} if this is a video call. */ public static void sendIncomingCallIntent(Context context, Uri handle, boolean isVideoCall) { PhoneAccountHandle phoneAccount = new PhoneAccountHandle( new ComponentName(context, TestConnectionService.class), CallServiceNotifier.SIM_SUBSCRIPTION_ID); // For the purposes of testing, indicate whether the incoming call is a video call by // stashing an indicator in the EXTRA_INCOMING_CALL_EXTRAS. Bundle extras = new Bundle(); extras.putBoolean(TestConnectionService.EXTRA_IS_VIDEO_CALL, isVideoCall); if (handle != null) { extras.putParcelable(TestConnectionService.EXTRA_HANDLE, handle); } TelecomManager.from(context).addNewIncomingCall(phoneAccount, extras); }
From source file:ca.rmen.android.poetassistant.main.dictionaries.search.Search.java
public void setSearchView(SearchView searchView) { SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); ComponentName searchableActivityComponentName = new ComponentName(mContext, mContext.getClass()); searchView.setSearchableInfo(searchManager.getSearchableInfo(searchableActivityComponentName)); }
From source file:net.dahanne.spring.android.ch3.restful.example.recipeapp.RecipesList.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate menu from XML resource MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.list_options_menu, menu); Intent intent = new Intent(null, getIntent().getData()); intent.addCategory(Intent.CATEGORY_ALTERNATIVE); menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, new ComponentName(this, RecipesList.class), null, intent, 0, null);//from w ww . ja va 2 s.c o m return super.onCreateOptionsMenu(menu); }
From source file:edu.umich.flowfence.common.QMDescriptor.java
public static QMDescriptor forInstance(Context context, Class<?> definingClass, String methodName, Class<?>... paramTypes) { if (!ParceledPayload.canParcelType(definingClass)) { throw new ParcelFormatException("Can't parcel instance type"); }/*from www . j av a 2s. c o m*/ return new QMDescriptor(KIND_INSTANCE, new ComponentName(context, definingClass), methodName, toNames(paramTypes), false); }