ContactDetailActivity from Lockscreen Activity - android

I have created a lockscreen widget that starts a custom activity when a click is performed on it. This activity displays a few predefined user selected contact names. When the user click on one of these names, I would like to display contact's information.
Since I have the contact ID when I click on the contact display name, I use an intent to redirect to the builtin ContactDetailActivity by using the following piece of code:
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri =
Uri.withAppendedPath(
ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactId));
intent.setData(uri);
intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
The problem is that I have to unlock the screen to see the contact activity that displays information. I think the problem is due to the fact that I haven't specified flag WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED for ContactDetailActivity, however I cannot figure out how to do nor if it is possible?
Is there a simple mean to achieve my purpose. Otherwise, the last solution I see is to create a custom activity that behaves like ContactDetailActivity so that I can put the WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED flag. However, it seems overkill.

why you don't use QuickContactBadge instead ? here android has good tutorial in how to use it Android Displaying the Quick Contact Badge

Why not dismiss the keyguard when launching the activity with FLAG_DISMISS_KEYGUARD?

Related

Invoke system contact app and retrieve data android

Im developing an application where in I have 2 text views and a button.
when I click the button, it should open default system contacts application and upon selecting a contact, it should display the name and number in the text fields respectively.
Now I have implemented ContactsContract and getContentResolver. But, I have seen other apps having this feature, which is quite easy because you need not create a list view and stuffs.
Now how do I start? how do I invoke default contact app and retrieve data from it.
I don't know the details about your problem, but I am pretty sure that you need to use an Implicit Intent (because the Contacts app may be different on different devices). Hopefully this page will help.
You may need to start by using this code:
Intent i = new Intent(); // Declare intent
// Start the intent
startActivity(i);
You may want to use ACTION_GET_CONTENT.
Thanks for the replies. I found out that this is what i need.
Intent localIntent = new Intent("android.intent.action.PICK",ContactsContract.Contacts.CONTENT_URI);

Retrieving data with the help of intent-filter

In my application, I have an intent-filter registered for one of my activities. When I click on a number in sms/e-mail, dialog is displayed whether I want to call though the standard dial of my phone of though the activity with intent-filter. What I want to do is not just open a particular activity, but also retrieve the number, that was clicked. Is it possible to do?
add the relative info while initializing your intent and then broadcast it.
for example:
Intent i = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:000000000"));
where 000000000 is your desired telephone number which may take out from any selected view
use intent.putExtra("key", "value") to set phone number in your intent before sending it, and at receiving side take this value out from your received intent

Using Activity Group

I want to use ActivityGroup to run two activities, but the catch is that those are not necessarily Activities I wrote, for example, I may want to open a contact picker or something that was part of the system. Is this possible? Using the ndk maybe?
EDIT: I want to run both activities on-screen at the same time.
I'm not sure that i understood your question. But if you want to start an activity from another one, you can simply use:
this.startActivity(new Intent(String intent));
Were the parameter of Intent should be the component name of a registered activity, the action or a specific class of your application that you want to start.
i.e. to open a contact detail:
this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, ""+contactId)));
take a look here to have a deep view on intent

Show another activity in a layout in Android?

I have an application that displays contacts from the contact book. This isnt hard:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, ""+contactId));
startActivity(intent);
However, I would like my apps banner to still be showing on the top of the screen. Is there any way to show this new activity as part of my own layout, so I can have my banner and some buttons, and then show the contact in a FrameLayout at the bottom?
Cheers,
The answer is: It is impossible. A securityException is always thrown because my app does not have the correct process ID to run that intent within my own activity.

how can we open the android contact activity programatically?

Can you please tell me how can i open the android inbuilt View Contact Activity
Programatically.
I am having a list of contacts in my activity and i want to show the contact details on the selection of list Item, so i basically want to know to which android activity i should send the intent in order to open that activity.
Thanks in Advance.
Use the ACTION_VIEW action in your intent, with the content://contacts/people/1 URI (see javadoc of Intent for more details)
If you want to reach Contacts in Android, you probably want to read on in the Contacts class.

Categories

Resources