Custom title for links on contacts - java

I am working on an app which saves users social networks links in the default contacts app provided by Android OS.
I am able to save link in the app but I am not able to customize the title as you can check in the image below of Default Contacts App:
I am using below code to save linkedin url as an example for now but I want to save it as linkedin title instead of Website and also linkedin icon.
Current Code block:
if (loginResponseData.getLinkedin() != null) {
ContentValues values = new ContentValues();
values.put(ContactsContract.Data.RAW_CONTACT_ID, contactid);
values.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Website.CONTENT_ITEM_TYPE);
values.put(ContactsContract.CommonDataKinds.Website.DATA, loginResponseData.getLinkedin());
fragmentActivity.getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values);
}

For each Data type you want to persist into the Database, you should go into the documentation and check which fields it supports and you might want to fill them in your insert call.
You can check here: https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Website
That CommonDataKinds.Website supports the fields URL, TYPE and LABEL.
The text that appears below the url in the contacts app is the label field.
So your code can look something like this:
ContentValues values = new ContentValues();
values.put(Data.RAW_CONTACT_ID, contactid);
values.put(Data.MIMETYPE, Website.CONTENT_ITEM_TYPE);
values.put(Website.URL, loginResponseData.getLinkedin());
values.put(Website.TYPE, Website.TYPE_CUSTOM); // when this is set to CUSTOM, the contacts app will display the label field
values.put(Website.LABEL, "Linkedin");
contentResolver.insert(android.provider.ContactsContract.Data.CONTENT_URI, values);

Related

How to give each request a sequential ID in android application?

I know this question may seem ambiguous to many users, but I'll try to elaborate the question in brief. I'm trying to build an object recognition application through android. The photo captured by the camera will be send to firebase database and from there the photo will be fetched by python script and recognition of image will be done. So my question is how can I code for an application which will push image from application to the database such as key of captured images by user(any application user) will be in sequence:
image1, image2, image3....
It implies that if 'a' user capture an image, photo will be uploaded to database with key 'image1'. After when user 'b' takes a photo, image will be pushed with the key 'image2'. Note that the application can be used by number of users simultaneously. So any suggestions on how should I implement this in android?
First, authenticate the user then get the id of each user and store in the database that way its easier to retrieve later on.
like this:-
DatabaseReference ref =
FirebaseDatabase.getInstance().getReference("users");
Firebase user=FirebaseAuth.getInstance().getCurrentUser();
//to send to database
ref.child("uid").setValue(user.getUID());
Now you have the userid under users, then under userid add an image.
So example:
{
"users":{
"userid":{
"name": "peter"
"image": "link_from_storage"
}
}
}
This way everytime a user captures an image he will have a userid for him.
Now for the image, you have to send it to the firebase storage and then take the link from there and store it in the database.
Example:
StorageReference filepath=mStorage.child(uri.getLastPathSegment());
filepath.putFile(uri).addOnSuccessListener(new
OnSuccessListener<UploadTask.TaskSnapshot>() {
#Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
String downloaduri=taskSnapshot.getDownloadUrl().toString();
Basically the first line, you are adding the image to the firebase storage.Then you do a listener to get the image url from storage and put it in downloaduri.
Then to add image in database:-
ref.child("image").setValue(downloaduri);
Hope this helps!
The last time I used firebase was about 8-10 months back so I do not remember the syntaxes.
You can use Firebase's could storage to upload your images to cloud when users upload it. You can generate an id (key) accordingly and save it in the database with the reference to that image as the value to that key. You can read here how to do that.
Fortunately, Firebase functions can then be used with the Cloud storage to access and process the image. You just need to read about Cloud storage triggers.
you have to maintain some thing like this if im not wrong
Place holder folder image in firebase file system.
Place holder forder image_name, uploaded user_name(if required based on your needs) and time_stamp at what time uploaded.
Now first fetch the image_names, with timestamps and then based time stamp fetch images files.

How to get attachment details (who uploaded and in which activity) in a workflow in documentum

I have created a workflow template having some manual activities. Performers of these activities are groups and any user from these groups can attach some documents to the workflow when they get respective work item in their inbox. Is there any way to differentiate who has attached what document in which activity?
IDfCollection listAttachment = wf.getAttachments() provides me all the attachments in the workflow. Is there any way to differentiate which user has attached which document in which activity?
Since you wrote DFC code I suppose you want this via code:
IDfCollection listAttachment = wf.getAttachments();
while(listAttachment.next()){
((IDfWorkflowAttachment)listAttachment).getCreatorName(); // return who has add it
((IDfWorkflowAttachment)listAttachment).getCreationDate(); // return when was added
}
Unfortunately you can find out in which activity it was added.
Check this link for IDfWorkflowAttachment javadocs.

is there a way to get user created playlists using the youtube java library?

I have code like this; and it works fine. but I would like only user created lists. Is this possible?
*/
ChannelListResponse clr = youtube.channels()
.list("contentDetails").setMine(true).execute();
// Get the user's uploads playlist's id from channel list
// response
String uploadsPlaylistId = clr.getItems().get(0)
.getContentDetails().getRelatedPlaylists()
// I want user created lists not uploads or
// favorites
.getUploads();
I have just looked at youtube data api v3 (I didn't use before just looked at api.).
It seems, it provides PlaylistListResponse then you can get Playlist items and theirs ids.

how save value in android to acces other page

in android how we save one value to acces on each page,
for example I am making a login app
and I need user_id to each page for access data from db by this id
or
I am in home page and I want to store user_id ,and I need to access this on any page ,
for example home=>profile=> change password,
I want to access user_id here to change password
I am trying
Intent slideactivity = new Intent(login.this, LoginMenu.class);
slideactivity.putExtra("uName", n);
but When I access it it give empty value on create_password activity
You can use Shared Preferences. Please have a read.
http://developer.android.com/guide/topics/data/data-storage.html#pref
Hope this helps.
Also... a previous stackoverflow answer may help you out in this scenario. Have a look here...
How do I pass data between Activities in Android application?
Hope this also helps.

Android: Get dummy icon of a contact

In Android: I would like to get dummy icon assign to a contact. I'm able to get if there's any image assign to the contact with contact-id.
Try this url Retrieve System Default Android Contact Picture.
I think this image is private to Contacts application and you may get the image from
\android-sdk\platforms\android-v#\data\res\drawable\

Categories