Issue with Intent.ACTION_SEND? - android

eTSubject = (EditText) findViewById(R.id.eTSubject);
eTContent = (EditText) findViewById(R.id.eTContent);
subject = eTSubject.getText().toString();
content = eTContent.getText().toString();
iBMail.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
i = new Intent(android.content.Intent.ACTION_SEND);
i.setType("plain/text");
i.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { "" });
i.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
i.putExtra(android.content.Intent.EXTRA_TEXT, content);
startActivity(Intent.createChooser(i, "Continue with send?"));
}
});
Above is my piece of code, which is trying to send email with some text i'm tryin to put in email screen and amazingly not getting that content when email screen is opening. Anyone have any idea why is it not working?
Any help will highly be appreciated.
mrana..

Guys i have solved this issue. If any of you are facing such kinda issue then all you have to do is to put your string variable where you are getting the text and changing the edittext into string within your click method which you are triggering from the view by pressing any widget.

Related

Sending email to three email id's with intent in android

I want to send email to three email id's at once if the button is clicked, via the email clients installed in the user's phone.
I am using the code below, as it is a onClickListener and Switch case:
public class ContactInfo extends Activity implements OnClickListener {
Button bcall,bmail;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.contactinfo);
bcall=(Button)findViewById(R.id.bcall);
bmail=(Button)findViewById(R.id.bmail);
bcall.setOnClickListener(this);
bmail.setOnClickListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent launch;
switch(v.getId()){
case R.id.bcall:
launch = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:+10000000"));
startActivity(launch);
break;
case R.id.bmail:
launch = new Intent(android.content.Intent.ACTION_SEND);
launch.setType("text/plain");
launch.putExtra(Intent.EXTRA_EMAIL, new String[]{"abc#gmail.com", "web#gmail.com", "def#gmail.com"});
launch.putExtra(Intent.EXTRA_SUBJECT, "restaurant");
launch.putExtra(Intent.EXTRA_TEXT, "Sent via - Android Application");
try{
startActivity(launch);
}catch(android.content.ActivityNotFoundException ex){
Toast.makeText(ContactInfo.this, "There are no Email Clients", Toast.LENGTH_LONG).show();
}
break;
}
}
It is working but it is not taking any given email addresses in the email id column.
Use it like below.
launch = new Intent(Intent.ACTION_SEND);
launch.setType("text/plain");
launch .putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {
"abc#gmail.com", "abc#gmail.com" });
launch .putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
You have to use new String[] array to send email to multiple people. Also change ACTION_SENDTO to ACTION_SEND...
Hope this will help you.
change
launch.putExtra(Intent.EXTRA_EMAIL, "emailid#1.com, emailid#2.com, emailid#3.com");
to this :
launch.putExtra(Intent.EXTRA_EMAIL,new String[]{
"emailid#1.com, emailid#2.com, emailid#3.com"});

Catch the Click Event of the Hyperlink from the Entire String in Android

I am receiving a String Response from the WebService which I have stored in a String Variable.
Sometimes I get the Hyperlinks in that String Response for Which I have implemented the Logic to Catch the Link.
I m showing that String Response in an Alert Dialog.
My Concern is that I need to Open the Link on the Click to that Link, not as soon as it find the Link in the String which is the Case happening right now.
My Code :
String strTipsMessage = beanTXTIconShowTips.getTips();
if (strTipsMessage.contains("http"))
{
String strHyperLink = strTipsMessage.substring(strTipsMessage.indexOf("http"), strTipsMessage.length());
if (strHyperLink != null)
{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(strHyperLink));
startActivity(intent);
}
AndroidLog.i(TAG, "strHyperLink : --- " + strHyperLink);
AndroidLog.i(TAG, "Tips_Message : --- > " + strTipsMessage);
}
Utility.showDialogForTips(ActConversations.this, "Tip of the Day...", strTipsMessage, R.drawable.icon_tips, "Ok");
Thanks,
David
I think Linkify is the thing which you are looking for. You can make your text linked to some URL so when it gets clicked, it function appropriately.
Refer this and this link.
As i under stood your problem. I can suggest you to make a TextView and set the text or the url value to that TextView. Add a click listener to that TextView and fire the intent when a user clicks the url text.
Code
TextView t = (TextView) findViewById(R.id.url);
t.setText("http://developer.android.com/training/animation/screen-slide.html");
t.setOnClickListener(clickListener);
here is the listener which listen the textview click
OnClickListener clickListener = new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
TextView vi = (TextView) v;
//Toast.makeText(getApplicationContext(), vi.getText(), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(vi.getText()));
startActivity(intent);
}
};

Calling by Clicking the Number -- Android

I am trying to have it so that when the phone number is clicked, it makes a call. The phone number is displaying correctly, but nothing happens when I click it.
Why is this not working?
tvInfo.setText(Html.fromHtml("<a href='tel:15555555555'><b>(555) 555-5555</b></a>"));
Let me know if more information is needed. Thanks!
Try looking at Linkify. Set the phone number normally with setText, and then use Linkify.
tvInfo.setText("(555)555-5555");
Linkify.addLinks(tvInfo, Linkify.PHONE_NUMBERS);
Try this:
call.setText(Html.fromHtml("<u>" + "9999999999" + "</u>"));
call.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
number = call.getText().toString();
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + number));
startActivity(intent);
}
});

Make call on number click

I need a little help.
I have ,in my app, a textView which contains a phone number,and i want to make a call when i click that phone number.
I've already accomplished that:
sitePhone.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
String number = "tel:" + sitePhone.getText().toString().trim();
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(number));
startActivity(callIntent);
}
});
Now the problem is that sometimes i have on my text view 2 or 3 phone numbers.Something like this: "07456443345 FAR: 0745456334".I take the phone number string from the database so it cannot be altered.
Any ides of how i can make a call on each number click? thanks in advance
i found a simple answer:
android:autoLink="phone" will to the trick.

Mail screen scrolls down to the bottom

I am invoking a mail intent in
ImageButton mail=(ImageButton)findViewById(R.id.mailgps);
mail.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
setContentView(R.layout.mail);
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
// TODO Auto-generated method stub
emailIntent.setType("text/plain");
String emailto[]={"myemail"};
String subject="GPS User Report";
String body="Welcome to Samarth Reporting service.Did you see an untracked Dustbin\n.A dustbin not at the right place??\nWant to suggest placement of a dustbin here.\nGo ahead we are all ears.\n.Your present location is\n Latitude: ";
body=body + "28.67890" + " and Longitudes: " + "79.78965";
body=body + "\n\nTell us more.";
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,emailto);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,body);
startActivity(emailIntent);
}
});
and getting the screen like this which ignores the EXTRA_EMAIL attribute as well as EXTRA_SUBJECT and then the body appears at the very bottom.How can I rectify this.??
Well it was a pretty stupid thing.
As earlier I was using another AVD I had the email client setup so it worked nicely.But on the new AVD I overlooked that.So "first" setup the email client then go for invoking intent.
Nonetheless the system should have a better way of handling such situations rather than showing a weird blank screen.

Categories

Resources