List of usage examples for android.content Intent setComponent
public @NonNull Intent setComponent(@Nullable ComponentName component)
From source file:com.quickblox.sample.chat.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. Log.d("!!!!!!!!!", "Wwe are in the onReceive but for some reason it isnt doing anything!"); 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 w w . j a va 2s . c om }
From source file:fr.shywim.antoinedaniel.gcm.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); // Start the service, keeping the device awake while it is launching. String msg = intent.getStringExtra("msg"); if (msg != null && msg.contains("update:")) { startWakefulService(context, intent.setComponent(comp)); setResultCode(Activity.RESULT_OK); } else {/*from w ww .j av a 2 s . com*/ context.startService(intent.setComponent(comp)); setResultCode(Activity.RESULT_OK); } }
From source file:edu.mines.letschat.GcmBroadcastReviever.java
@Override public void onReceive(Context context, Intent intent) { Log.v("GCM Demo", "in on reviece"); // Explicitly specify that GcmIntentService will handle the 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 a2 s . com String regId = intent.getExtras().getString("registration_id"); if (regId != null && !regId.equals("")) { /* Do what ever you want with the regId eg. send it to your server */ Log.v("PLEASE WORK", regId); final SharedPreferences prefs = getGcmPreferences(context); String password = prefs.getString("password", ""); String username = prefs.getString("username", ""); new RegisterUser("registerUser", regId, username, password).execute(); int appVersion = getAppVersion(context); SharedPreferences.Editor editor = prefs.edit(); editor.putString(PROPERTY_REG_ID, regId); editor.putInt(PROPERTY_APP_VERSION, appVersion); editor.commit(); } }
From source file:com.chale22.ico01.fragments.FragmentTheme.java
private void applyAdwTheme() { try {//from w ww . j a v a2s.c o m Intent adwlauncherIntent = new Intent(Intent.ACTION_MAIN); adwlauncherIntent.setComponent(new ComponentName("org.adw.launcher", "org.adw.launcher.Launcher")); startActivity(adwlauncherIntent); makeToast("Apply with \"ADW Settings\" in Menu"); } catch (ActivityNotFoundException e4) { e4.printStackTrace(); makeToast("ADW Launcher is not installed!"); } }
From source file:org.shaastra.helper.SuperAwesomeCardFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//w w w .ja va 2 s .co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.CENTER); //v.setBackgroundResource(R.drawable.background_card); v.setText("CARD " + (position + 1)); if (position == 0) { View v1 = inflater.inflate(R.layout.event_info, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView t1 = (TextView) v1.findViewById(R.id.infotext); t1.setText(eintroduction); return v1; } else if (position == 1) { String Venue = new String(); Venue = evenue; final String SAC = elatlong; //String start=String.valueOf(l.getLatitude())+String.valueOf(l.getLongitude()); /* View v1=inflater.inflate(R.layout.map, container,false); v1.setLayoutParams(params); WebView wv=(WebView)v1.findViewById(R.id.wv1); wv.setWebChromeClient(new WebChromeClient()); //wv.loadUrl("https://maps.google.com/maps?saddr=13,80&daddr=13,80.02"); //wv.loadUrl("http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false"); wv.loadUrl("http://maps.google.com/maps?f=d&daddr=51.448,-0.972"); wv.getSettings().getBuiltInZoomControls(); */ View v1 = inflater.inflate(R.layout.map, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView location = (TextView) v1.findViewById(R.id.locationText); Button mapButton = (Button) v1.findViewById(R.id.mapButton); if (evenue.equalsIgnoreCase("NONE")) { mapButton.setAlpha(0); } else { mapButton.setAlpha(1); } location.setText(Venue); mapButton.setOnTouchListener(new View.OnTouchListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) { v.setAlpha((float) 0.4); v.animate().setInterpolator(new DecelerateInterpolator()).scaleX(0.9f).scaleY(0.9f); } if (event.getAction() == MotionEvent.ACTION_UP) { v.setAlpha((float) 0.75); v.animate().setInterpolator(new OvershootInterpolator()).scaleX(1f).scaleY(1f); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?f=d&daddr=" + SAC)); intent.setComponent(new ComponentName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity")); startActivity(intent); } return false; } }); return v1; } else if (position == 2) { View v1 = inflater.inflate(R.layout.event_info, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView t1 = (TextView) v1.findViewById(R.id.infotext); t1.setText(eformat); return v1; } else if (position == 3) { View v1 = inflater.inflate(R.layout.prize, container, false); v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TextView t1 = (TextView) v1.findViewById(R.id.prizeText); t1.setText(eprize); return v1; } else if (position == 4) { v.setBackgroundColor(Color.GREEN); } else if (position == 5) { v.setBackgroundColor(Color.MAGENTA); } else if (position == 6) { v.setBackgroundColor(Color.MAGENTA); } fl.addView(v); return fl; }
From source file:com.mono.applink.Facebook.java
/** Called when the activity is first created. */ @Override//from w w w. j a va 2s. com public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = this; final String url = getIntent().getData().toString(); if (url.contains("posts") || url.contains("profile.php") || (!url.contains("&") && !url.contains("=") && url.length() > 24)) //1)Posts->It is impossible to launch FeedbackActivity because of permission denied. //With root permission and "am start" it's impossible to pass a Long extra_key... //2)Profile //3)Nickname { new FacebookUser().execute(); } else if (url.contains("sk=inbox"))//Message { new FacebookMessage().execute(); } else if (url.contains("event.php"))//event { new FacebookEvent().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.google.android.demos.jamendo.app.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.jamendo_list); Resources resources = getResources(); mImageSize = resources.getDimensionPixelSize(R.dimen.gallery_size); mResults = new Loadable(getSupportLoaderManager(), LOADER_SEARCH, new StatusViewManager(this, LOADER_SEARCH, this, this)); mAdapter = new SearchAdapter(this); ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(mAdapter);/* www. j av a2 s . co m*/ listView.setOnItemClickListener(this); Intent intent = getIntent(); String action = intent.getAction(); if (action.equals(Intent.ACTION_VIEW)) { // Forward intents from suggest system to correct activity // // TODO: Is there a way to force suggest system to // not set the component? intent.setComponent(null); startActivity(intent); finish(); } else { mResults.init(); } }
From source file:com.duy.pascal.interperter.libraries.android.connection.bluetooth.AndroidBluetoothLib.java
@SuppressWarnings("unused") @PascalMethod(description = "Connect to a device over Bluetooth. Blocks until the connection is established or fails.", returns = "True if the connection was established successfully.") public String bluetoothConnect( @PascalParameter(name = "uuid", description = "The UUID passed here must match the UUID used by the server device.") @RpcDefault(DEFAULT_UUID) String uuid, @PascalParameter(name = "address", description = "The user will be presented with a list of discovered devices to choose from if an address is not provided.") @RpcOptional String address) throws IOException { if (address == null) { Intent deviceChooserIntent = new Intent(); deviceChooserIntent.setComponent(Constants.BLUETOOTH_DEVICE_LIST_COMPONENT_NAME); Intent result = mAndroidFacade.startActivityForResult(deviceChooserIntent); if (result != null && result.hasExtra(Constants.EXTRA_DEVICE_ADDRESS)) { address = result.getStringExtra(Constants.EXTRA_DEVICE_ADDRESS); } else {/*from www. j ava 2 s . com*/ return null; } } BluetoothDevice mDevice; BluetoothSocket mSocket; BluetoothConnection conn; mDevice = mBluetoothAdapter.getRemoteDevice(address); mSocket = mDevice.createRfcommSocketToServiceRecord(UUID.fromString(uuid)); // Always cancel discovery because it will slow down a connection. mBluetoothAdapter.cancelDiscovery(); mSocket.connect(); conn = new BluetoothConnection(mSocket); return addConnection(conn); }
From source file:io.nuclei.cyto.share.PackageTargetManager.java
/** * Create an intent with package specific modifications * * @param authority The file authority provider to be used for sharing files * @param permissionRequestCode Some packages may require we put files on external storage, * this is the permission request code that will be used to request that permission *//* w ww .j a v a 2 s .c om*/ public Intent onCreateIntent(Activity activity, String authority, ResolveInfo info, int permissionRequestCode) { int maxLen = getMaxLen(info.activityInfo.packageName); String text = mText; if (maxLen != Integer.MAX_VALUE) text = trim(text, mUrl, maxLen); else if (mText != null && mUrl != null) text += '\n' + mUrl; Intent intent = new Intent(TextUtils.isEmpty(mEmail) ? Intent.ACTION_SEND : Intent.ACTION_SENDTO); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setPackage(info.activityInfo.packageName); onSetDefault(activity, info.activityInfo.packageName, authority, intent, text); switch (info.activityInfo.packageName) { case FACEBOOK: intent = onFacebook(activity, intent); break; case WECHAT: intent = onExternalStorage(activity, intent, permissionRequestCode); break; case INSTAGRAM: if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) intent = onExternalStorage(activity, intent, permissionRequestCode); break; } return intent; }
From source file:hku.fyp14017.blencode.ui.dialogs.NewSpriteDialog.java
private void setupPaintroidButton(View parentView) { View paintroidButton = parentView.findViewById(hku.fyp14017.blencode.R.id.dialog_new_object_paintroid); final Intent intent = new Intent("android.intent.action.MAIN"); intent.setComponent(new ComponentName(Constants.POCKET_PAINT_PACKAGE_NAME, Constants.POCKET_PAINT_INTENT_ACTIVITY_NAME)); paintroidButton.setOnClickListener(new View.OnClickListener() { @Override// w w w . j a v a 2 s. co m public void onClick(View view) { if (LookController.getInstance().checkIfPocketPaintIsInstalled(intent, getActivity())) { Intent intent = new Intent("android.intent.action.MAIN"); intent.setComponent(new ComponentName(Constants.POCKET_PAINT_PACKAGE_NAME, Constants.POCKET_PAINT_INTENT_ACTIVITY_NAME)); Bundle bundleForPocketPaint = new Bundle(); bundleForPocketPaint.putString(Constants.EXTRA_PICTURE_PATH_POCKET_PAINT, ""); bundleForPocketPaint.putString(Constants.EXTRA_PICTURE_NAME_POCKET_PAINT, getString(hku.fyp14017.blencode.R.string.default_look_name)); intent.putExtras(bundleForPocketPaint); intent.putExtra(MediaStore.EXTRA_OUTPUT, lookUri); intent.addCategory("android.intent.category.LAUNCHER"); startActivityForResult(intent, REQUEST_CREATE_POCKET_PAINT_IMAGE); } } }); }