Posts

Showing posts from August, 2018

Send the data to one app to another app using intent and broadcast - Part 2

Previous post I explain about the sharing the data using broadcast. This post about to share the data using the intents. By using Intent In First Application Intent intent = new Intent(); intent.setClassName("com.sample.app", "com.sample.app.MainActivity"); intent.putExtra("EXTRA_ORDERID", "#4FGT784"); intent.putExtra("EXTRA_ORDERNOTES", "No warranty for this product"); intent.putExtra("EXTRA_ORDERAMOUNT", "270"); PackageManager packageManager = getPackageManager(); List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0); boolean isIntentSafe = activities.size() > 0; if (isIntentSafe) { startActivity(intent); } else { Toast.makeText(MainActivity.this, "Application not installed", Toast.LENGTH_LONG).show(); } In Second Application Bundle vals = getIntent().getExtras(); if (vals != null) { String orderId = vals.getS

Send the data to one app to another app using intent and broadcast - Part 1

Hi Friends, Have a great day. It's my 75th blog. I'm very slow, but I'm post only necessary and important posts only, hope so. This time we'll look some manual broadcast message sending from another application, best way to for testing the notifications. By Using send broadcast. In First Application ComponentName componentName = new ComponentName("com.sample.app", "com.sample.app.receiver.NotificationReceiver"); Intent intent = new Intent(); intent.setComponent(componentName); String message = "Order ID:  #AER46798 "; intent.putExtra("EXTRA_TITLE", "New Order Received"); intent.putExtra("EXTRA_MESSAGE", message); sendBroadcast(intent); In Second Application Receiver public class NotificationReceiver extends BroadcastReceiver {     public static String TAG = "PCM";     @Override     public void onReceive(Context context, Intent intent) {         Log.i(TAG, "message_received");