Launch CallLog activity in android using Intent - android

I'm able to launch the Call Log activity using intent
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(android.provider.CallLog.Calls.CONTENT_URI);
startActivity(intent);
But on selecting any Log (incoming, Outgoing or missed ) from Call Log activity it will initiate a call.
But according to my requirement i want to use above intent using action Intent.ACTION_PICK and startActivityForResult(intent).
please share any idea to do the same.

Related

How to clear previously opened activity in Android

Intent intent = new Intent(MainActivity.this, Payment.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Opening coupon activity to apply coupon:
Intent intent = new Intent(Payment.this, Coupon.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
From coupon activity opening payment activity with updated data
Intent intent = new Intent(Coupon.this, Payment.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
The problem is, when I click on the back button on payment activity after applying the coupon, it opens the previously opened payment activity again (not the main activity).
onBackPressed() I don't want to do it static (like Intent intent = new Intent(Payment.this, MainActivity.class); and also don't want to use finish(); in payment activity.
Please help.
You can use FLAG_ACTIVITY_NO_HISTORY when launching the Payment activity.
See: https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NO_HISTORY
This is a Simple Use case of startActivityForResult don't make it complicated with Intent Flags and launch modes.
Whenever you Open your Activity Coupon just use startActivityForResult and upon applying coupon send the result back to previous Activity (success/failure) or whatever result you want . Then you can change the UI as per the result you got in onActivityResult() .
You can follow How to manage startActivityForResult on Android or the latest way from the doc Getting a result from an activity .

It is possible to start directly a call intent from one app to another without a chooser popup?

I have an app that sends a call intent to another app (CsipSimple).
Intent intent = new Intent("android.phone.extra.NEW_CALL_INTENT");
intent.setData(Uri.parse("csip:" + number));
startActivity(intent);
But every time a chooser dialog is poping up to choose the CsipSimple app. Is there a way to avoid this chooser and use directly a defined app.
I found that it is possible to define the class name of the activity:
intent.setClassName("com.csipsimple.ui.outgoingcall", "com.csipsimple.ui.outgoingcall.OutgoingCallChooser");
But this doesn't work, i assume that this can only work if the intent caller and CsipSimple are both in the same process.

Adding Intent to class in Applozic's Messaging SDK

Where should I add the foll.intent
Intent intent = new Intent(this, ConversationActivity.class);
startActivity(intent);
As of now, I've followed Applozic's instructions on github. But I am stuck at this.
I've a MainActivity, ApplozicGcmListenerService Class, GcmInstanceIDListenerService Class,GCMRegistrationUtils Class.
When selecting a contact to chat, you can call the ConversationActivity.java to open the chat window.
For example,
Intent intent = new Intent(this, ConversationActivity.class);
intent.putExtra(ConversationUIService.USER_ID, contact_user_id);
intent.putExtra(ConversationUIService.DISPLAY_NAME, contact_name);
startActivity(intent);
Before starting ConversationActivity intent you need to make sure that you have done the Applozic registration.
Where should I add the following intent?
You can start ConversationActivity intent on click of button or an menu option click as your app use case and it will show the list of conversations you have done so far.
You can check this sample code link and we started the ConversationActivity intent on navigation drawer menu item click

How do you check that if an intent has finished working?

I want to update an apk through code. However I need to establish a mechanism that checks when that application has updated. I need to somehow get a message back from the intent
Context ctx = getApplicationCOntext();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File("/mnt/sdcard/Download/update.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(intent);
This is the default mechanism to install an application. How can I check that if the intent has finished?
Use startActivityForResult() if you want data to be return from the called activity. For more details, read: Getting a Result from an Activity How to manage startActivityForResult on Android?

Accessing Android Inbox/Messaging from Activity?

Is it possible to open up the default Android Messaging activity from inside an activity you write yourself? Like for example: I press a "Mail" button inside my program, and it opens the Android Messaging app just like as if I was to press the Messaging icon on the main screen.
I did something similar to this with the Contacts activity, but only the contact list comes up, no extra functionality like Adding/Modifying/Deleting, etc.
Any ideas?
edit: I found this way to open the "Compose New Message" Activity, I just need to back it up a step. Does anyone know the correct MIME type instead of this one?
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("vnd.android-dir/mms-sms");
m_activity.startActivity(sendIntent);
This starts the messaging app from another app:
Intent intent = new Intent("android.intent.action.MAIN");
intent.setComponent(new ComponentName("com.android.mms","com.android.mms.ui.ConversationList"));
startActivity(intent);
Just put it inside a button listener or whatever user input you want to open it from.
Enjoy :-)
If you want to open the messaging app to view messages and not for sending a message, this should do the job:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setPackage("com.google.android.apps.messaging");
startActivity(intent);

Categories

Resources