Sending email to three email id's with intent in android - 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"});

Related

Make phone call without getting phone number (click icon to call) in android?

I'm currently working on my 2nd program and stuck with phone calling, sending SMS, emailing, and showing location using Google Map. I'm using ImageButtons for all of these. User doesn't need to type any numbers or addresses (not using EditText to get user input). However, it doesn't work.
For example, when user click on Phone icon, it will make a call. However, I still need a user input (the actual message, not the destination number or email address) for sending SMS and email. I can do it if I use EditText. However, without using EditText, I cannot do it. How do I do this? I've added users permission in manifest file.
PhoneActivity .java
public class PhoneActivity extends Activity {
ImageButton btnphonecall;
String phoneNumber = "091111111";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_phone);
btnphonecall=(ImageButton)findViewById(R.id.imageButton1);
btnphonecall.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i = new Intent(Intent.ACTION_CALL);
i.setData(Uri.parse("091111111"));
PhoneActivity.this.startActivity(i);
//I've tried startActivity(i) along but still doesn't work
}
});
}
Use this:
Uri number = Uri.parse("tel:"+091111111 );
Intent dial = new Intent(Intent.ACTION_CALL,
number);
dial.setPackage("com.android.phone");
PhoneActivity.this.startActivity(dial);
Try this:
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+phoneNumber));
startActivity(callIntent);

sending data from one app to another app in android(AIR for ANDROID)

As we can send data from one Activity to another within the app and also from one app to another app by using Intent
I'm able to send data from my one app to another by using following code
just consider there are two apps APP1 and APP2 and I'm sending data from APP1 to APP2 and vice verse.
In APP1 package name: (com.sush.myApp)
public class HomeActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
// to receive data from com.my.demo package and display it to TextView
TextView mText = (TextView)findViewById(R.id.textView1);
String name=getIntent().getStringExtra("User_Message");
mText.setText(name);
// to send data from com.sush.myApp package to com.my.demo package
Button btn1 =(Button)findViewById(R.id.button1);
btn1.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
try
{
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage("com.my.demo");
i.putExtra("User_ID", "sush19");
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
}catch(Exception e)
{
e.printStackTrace();
Toast.makeText(v.getContext(), "App Not Found", Toast.LENGTH_LONG).show();
}
}
});
}
and from APP2 package name: (com.my.demo)
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// to receive data from com.sush.myApp package and display it to TextView
final TextView txt1 = (TextView)findViewById(R.id.Text1);
String name=getIntent().getStringExtra("User_ID");
txt1.setText(name);
// to send data from com.my.demo package to com.sush.myApp package
Button btnSending = (Button)findViewById(R.id.btnSend);
final EditText myMessage = (EditText)findViewById(R.id.txtMessage);
btnSending.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
if (myMessage.getText().toString().equals(""))
{
Toast.makeText(v.getContext(), "Enter your message", Toast.LENGTH_SHORT).show();
}
else
{
try
{
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage("com.sush.myApp");
i.putExtra("User_Message", myMessage.getText().toString());
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
}catch(Exception e)
{
e.printStackTrace();
Toast.makeText(v.getContext(), "Error: "+e, Toast.LENGTH_LONG).show();
}
}
}
});
}
And its working perfect..
Now my problem is I want to do same operation i.e sending data from one app to another but my first app is in Java created using Eclipse and my second app is in ActionScript created using AIR for Android in Adobe Flash Professional CS6
Is there a way to use Intent and PackageManager in Actionscript so that I can send the data easily from AIR app to Android App, if yes then can anyone show me a example
Or else can anyone show me an example on how to send data from Android App to AIR for Android App and vice verse..
Thank you...
There's 2 methods I can think of for this.
The first is to use the Java code you have written (or similar), package it as a Native Extension, and build that into your app.
Another alternative is to use a URI scheme and read the data from the InvokeEvent. This SO question covers that method already.

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

open radio buttons in different class

I am building a login system in android and i need to accomplish the following:
save userdata on the local storage
when a user is created and i press on the button it needs to dynamically create a radiobutton with the user name and short name in it.
I have already managed to accomplish these things, but the only problem i have now is that i want to to have 2 classes, one where you register your account and the other where the radiobuttons with the user data is displayed. So my question: how can i program the calss in such a way that when i press on the register button that it creates the radiobuttons in a different class.
beneath is the code of the classes:
enter code here
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.Save:
Intent I = new Intent();
I.putExtra(
I.setClass(this, ShowUsers.class);
startActivity(I);
break;
}
}
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
// Start other Activity
switch (v.getId()) {
case R.id.create:
Intent intent = new Intent();
intent.setClass(Main.this, Register.class);
startActivity(intent);
break;
}
Bundle extras = getIntent().getExtras();
String userName;
if (extras != null) {
userName = extras.getString("editTextName,editTextPassword,editTextshortname");
// and get whatever type user account id is
}
}
}
when i click the save button it needs to create the radio button in the main class, now the question is how can i accomplish this?
If the second class is an Activity, then one solution is to send it an Intent with the data it needs to create the radio buttons. You do this by creating an Intent object, calling any of its setExtra() methods, then calling startActivity() with the Intent. Check out the Android API docs for more details.

Issue with Intent.ACTION_SEND?

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.

Categories

Resources