Show another activity in a layout in Android? - 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.

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);

ContactDetailActivity from Lockscreen Activity

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?

Back to my application when call direction from google map in Android

I have an application get direction via google map. Example Activity A call google map:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(myuri));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
startActivity(intent);
It show
Image 1: http://flic.kr/p/eBnRCy
then show
Image 2: http://flic.kr/p/eBjGWn
How to from image 2, I can back again my application(Activity A), don't back again image 1. Thanks a lot.
You may try to hack it with Intent.FLAG_ACTIVITY_NO_HISTORY, which removes first Activity as soon as a second is opened. This will work if the two screens you put into question are two instances of Activity (even if they are the same class).

Show Intent.ACTION_PICK in landscape

I am working on an app which let users choose photo from their gallery. The problem is I need to show the gallery in landscape only. Is it possible to do it?
I use this code:
Intent galleryIntent = new Intent(Intent.ACTION_PICK,MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent, RQC_GALLERY);
When you start any activity using explicit intent, you loose control from your application. Android finds out and application to perform that is described in intent object.
Intent object attributes details
From no where you can have control on next application regarding view.
If you want to fulfill specific requirement than make your own activity with Grid view and use image adapter to set images.
Here is one link which shows how to set images in adapter. It will help to design your code if necessary.

How to display the activity into full screen and vice versa on tapping the activity?

In my application, i am using Tabhost and I have placed the webview inside tab host to show the contents.When the user taps the screen the contents should be displayed in fullscreen and vice versa but this is not happening.How to acheive this?Please Suggest me some ideas !
thanks
Use
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
this code on your eventlistener.

Categories

Resources