Open add contact activity android sdk 2.1 and above - android

i am using the following code to open android defaults add contact activity to add contact in phone.
Intent intentInsert = new Intent(Contacts.Intents.Insert.ACTION);
intentInsert.setData(People.CONTENT_URI);
startActivity(intentInsert);
But its showing deprecated when using in android sdk 2.1 and above.
how to show add contact activity in new contacts contract api.
Thanks

try this
Intent i = new Intent(Intent.ACTION_INSERT_OR_EDIT);
i.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
i.putExtra(Insert.NAME,"Name");
i.putExtra(Insert.PHONE,"Number");
startActivity(i);

yes above method got deprecated after 2.1 or above try to use
intentInsert.setData(ContactsContract.CONTENT_URI);
for sdk 2.1 or above

Related

Uninstall application programmatically Android 10

I am developing an application which will uninstall itself after a button click. The following code works for the uninstallation of application running in Android.
Uri uri = Uri.fromParts("package", getClass().getPackage().getName(), null);
Intent uninst_intent = new Intent(Intent.ACTION_DELETE, uri);
startActivityForResult(uninst_intent, EXIT_REQUEST);
But this is not working for the new versions of android such as Android 9 and 10. This Action intent is not deprecated in the newer APIs. What am i missing here?
There is permission missing in Manifest please add this permission in manifest...
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES"></uses-permission>
this will work...!!!

Could not use the standard linking in my app

I have just updated the new Uber app (January 8, 2018) and the deep linking is not working.
Could you explain more?
Below is my code:
formattedUrl = String.format("uber://action=setPickup&client_id=%s&dropoff[latitude]=%f&dropoff[longitude]=%f",
mClientId, http://to.lat , to.lng);
Uri uri = Uri.parse(formattedUrl);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(uri);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(i);
With the old version of Uber app, my code works well. It shows the correct the pickup & drop off location but in the new app, it doesn't work.
May be they have updated things on this in their application.
You can generate deep link using this link.

Android TAKE_PHOTO_WITH_DATA cannot be resolved to a variable

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent,TAKE_PHOTO_WITH_DATA);
Hi all,I got two questions.
the code above show an "TAKE_PHOTO_WITH_DATA cannot be resolved to a variable" error,
I use sdk 2.2.3 but change to 4.2.2 the error still there,
what's wrong with "TAKE_PHOTO_WITH_DATA"?
by the way,
Is there any "TAKE_VIDEO_WITH_DATA" or "TAKE_SOUND_WITH_DATA" can use?
thanks a lot.
It will show an error as long as you don't declare the particular variable,TAKE_PHOTO_WITH_DATA is nothing but a request code,you can even use an integer directly instead of this like startActivityForResult(intent,1); it is just for checking the results you can read more about request codes in the android developer site

Showing prefilled contact screen to user on android 1.6

I have got following project requirment.
When user has given android.permission.WRITE_CONTACTSpermission in his manifest then we should add contact programatically. ( This part is done and working perfectly).
Now the challenge is If user has not given this permission then i will not able to add contact programatically but the best effort i want to put is show him prefilled contact screen and let him press add button.
I got this working on Android 2.0 and up.But I am facing issue to make it work on android 1.6 device.
Below is the code which works on Android 2.0 and up.
Intent i = new Intent(ContactsContract.Intents.Insert.ACTION,
ContactsContract.Contacts.CONTENT_URI);
i.putExtra(ContactsContract.Intents.Insert.NAME, "Vipul Shah");
i.putExtra(ContactsContract.Intents.Insert.PHONE, "1234");
startActivity(i);
Any help will be highly appreciated.
Thanks
This is because ContactsContract is only present in API5+ (Android 2.0) environments.
The relevant class in pre-API5 is called Contacts
if (android.os.Build.VERSION.SDK_INT > 5)
Intent i = new Intent(ContactsContract.Intents.Insert.ACTION,
ContactsContract.Contacts.CONTENT_URI);
i.putExtra(ContactsContract.Intents.Insert.NAME, "Vipul Shah");
i.putExtra(ContactsContract.Intents.Insert.PHONE, "1234");
startActivity(i);
} else {
Intent i = new Intent(Contacts.Intents.Insert.ACTION,
People.CONTENT_URI);
i.putExtra(Contacts.Intents.Insert.NAME, "Vipul Shah");
i.putExtra(Contacts.Intents.Insert.PHONE, "1234");
startActivity(i);
}

how to create Intent.ACTION_CALL_PRIVILEGED from code in android?

I was following this post to create a call. I know I can use ACTION_CALL/ACTION_DIAL but they will not meet my need. It suggested that I need to use #hide annotation. I was wondering how to do that.
(sdk 2.2) When I put the following code in eclipse shows red mark under Intent.ACTION_CALL_PRIVILEGED.
Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
Uri.fromParts("tel", number, null)); startActivity(intent);

Categories

Resources