Create my own custom keyboard with my own images - android

On Android, I need to create my own IME which lets users to choose an image and send it right away to the already open WhatsApp, Email, Facebook, etc window,
without showing any extra chooser (cause we're already working with the contact we wnat to send the image to).
To have a better idea, it should work as an emoji keyboard but using my own images, similar to the Ikea emoticons app.
I've already tried with Intent, but couldn't find a way to point it to the already active contact window.
Here's the code:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setPackage("com.whatsapp");
sendIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
sendIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
sendIntent.setType("image/jpeg");
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(sendIntent);

Related

How to make app picker for sharing text permanent in Android?

I'm trying to make refer and earn activity in my appSo I want to permanently display a few apps like whatsapp, etc for the user to click on them and share directly.I'm using Intent to share the referral code but it pops up the apps list when the user clicks share.The code I'm using is,
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "This is a message");
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "Share via"));
How can I make the app chooser permanent for a few apps?
The app chooser is not intended to be displayed permanently. Therefore you will have to create simple buttons or icons and create an intent that refers to the desired app directly, by setting the package of the intent.
E.g. to share sth with WhatsApp use sth like this:
Intent sendIntent = new Intent();
// here comes the magic
sendIntent.setPackage("com.whatsapp");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
Depending on the type of content you want to share and the apps you want to share with, it makes sense to reuse the code to create the intent and just set the respective package and eventually some additional parameters.
You will need package name of app and a Intent.
change ACTION_VIEW to ACTION_SENDTO
set the Uri as you did set the
package to whatsapp
Intent i = new Intent(Intent.ACTION_SENDTO,
Uri.parse("content://com.android.contacts/data/" + c.getString(0)));
i.setType("text/plain");
i.setPackage("com.whatsapp"); // so that only Whatsapp reacts and not the chooser
i.putExtra(Intent.EXTRA_SUBJECT, "Subject");
i.putExtra(Intent.EXTRA_TEXT, "I'm the body.");
startActivity(i);
You can refer this link for More:
Send text to specific contact (whatsapp)
Sending message through WhatsApp
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("*/*");
intent.setPackage("com.whatsapp");
intent.putExtra(Intent.EXTRA_TEXT, "your text content");
startActivity(intent)
I am facing same problem for share tamil font content in Whatsapp. I found the solution, this setType("*/*") share full content.

Problems sharing text with the new Android Studio

I have a simple app that will, at some point, generate a string of text that I want to share with any other app installed on the phone that can take a string of text (twitter, facebook, etc.)
Here's a sample of what I'm trying to do:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
This is from: https://developer.android.com/training/sharing/send.html#send-text-content
However, Android studio says it "cannot resolve" startActivity and suggests that I do this:
import static android.support.v4.app.ActivityCompat.startActivity;
Ok, so I do that and now startActivity() is expecting three inputs. This seems to be a new requirement because of an update. All the code examples I've seen only give it two inputs at most. The expectation is:
An activity???
The intent, which we defined
The bundle/extra options which I am leaving null
How do I satisfy the first input? Will it be possible to redirect back to my app after the sharing function is complete?
try this
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is my text");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "This is the title");
startActivity(Intent.createChooser(sharingIntent, "Share using"));
setting title is not compulsory. then the "share using" is just a text which you can replace with anything you want. its just shows above all suggested application

Android Share intent - issue with Facebook

I need to share text and one image from my application via a share intent. I read this article. I thought it would be easy to create share intent. But it is not so easy, because there is a problem with sharing via Facebook.
I need to share some text and one image, which is stored in device. My first attempt looked like this:
The first try
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/img.jpg")));
shareIntent.putExtra(Intent.EXTRA_TEXT, "My custom text...");
shareIntent.setType("image/jpg");
startActivity(Intent.createChooser(shareIntent, getString(R.string.label_share)));
I tried this code and in applications like Gmail, Google+, Google Keep, etc, everything works fine. But Facebook did not work fine.
There is no my text ("My custom text...") in this screenshot. So I have tried something else.
The second try
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/img.jpg")));
shareIntent.putExtra(Intent.EXTRA_TEXT, "My custom text...");
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, getString(R.string.label_share)));
And the result of this is here:
There is no text and also no image in this screenshot.
I also tried to change type to image/* and */*, but it did not help. I do not know what is wrong. I just need to share some text and image via Facebook. The first try works well for other applications, but for Facebook not.
Can someone help me, please?
Your first attempt is OK, Facebook does not allow sharing text this way, they say "Pre-filling these fields erodes the authenticity of the user voice."

how to make clicking on the item in "share" form with android espresso test

Trying to test the share function of the app, which is in the app it calls createChooser() to open the "sharing" chooser form.
startActivity(Intent.createChooser(sharingIntent, "Share something"));
Question is after the "sharing" chooser form is up how to simulate the clicking on some listed apps item, lets say there is app has description "AppName". Tried following it does not work, the chooser form stays there until the test timeout.
tried:
onView(withContentDescription("AppName"))
.perform(click());
and:
onView(withText("AppName"))
.perform(click());
Below is the example to share something in whatsapp:
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
waIntent.setPackage("com.whatsapp");//package name of whatsapp
waIntent.putExtra(Intent.EXTRA_TEXT, "Share Something");//text to share
startActivity(Intent.createChooser(waIntent,"Share via..."));
I hope this might help you.

how to add a Ymail/Gmail share button in android app?

hi friends i have a custom list coming from server and i want to add two share buttons for Gmail and Ymail resp. in that , its like when i click the Ymail share button it asks for username and password and then redirects me into the compose message section with message body as the link of the respective list and then i can access my contacts to send it to anyone i like.
1. please tell me how to do this??
2. is there any sdk available for Ymail/gmail
please suggest something..thanks in advance
to share text you don't pick the app you want to use. You pick the type of app you want to use. You can simply start an ACTION_SEND intent.
public void help() {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
String s = getString(R.string.sharesubject);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, s);
startActivity(sendIntent);
}
(source: android.com)
How about a share action provider its brand new. my 1st app has a share action provider and it looks a little like this.
Basically you just fill up a share intent with the message and attach the intent to the share menu item.
search for share action provider example
Good Luck

Categories

Resources