Ok, so what im trying to see if can be done. So i have a basic form submission for my application. Where the user can fill out some information such as a support request. This consists of several edit texts and view texts. Then its has a little text builder code in it to merge the text together and intent's to the android system for output via email.
So what i want to know is how i can add a image into this factor.
public void onClick(View v) {
String[] recipients = new String[]{"email#email.com", "email#email.com",};
String subject = textSubject.getText().toString();
String message = "Name:\n" + nametext.getText().toString();
message += "\n\nEmail:\n" + emailtext.getText().toString();
message += "\n\nContact#:\n" + phonetext.getText().toString();
message += "\n\nTopic:\n" + topictext.getText().toString();
message += "\n\nDescription:\n" + detailstext.getText().toString();
message += "\n\n" + sentby.toString();
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
//email.putExtra(Intent.EXTRA_CC, new String[]{ to});
//email.putExtra(Intent.EXTRA_BCC, new String[]{to});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
//need this to prompts email client only
email.setType("message/rfc822");
//plain text
email.setType("text/plain");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
finish();
}
});
So here is the example code for the string builder code to merge whats being typed inside the edit text forms on the xml layout file.
Now what im trying to figure how to do, is what code i would need to add a insert image button on my xml layout, the code to select the image from the user's file manager or gallery app and then how i could add that into the overall intent to send via email.
Any suggestions, feedback, source code examples and anything helps. Thanks in advance.
UPDATE
i have found the below code, and want to know if anybody has used this and if it will work in my above code.
sendIntent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");
you need to use android.net.Uri
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/mysong.mp3"));
it's work to attache file to email.
Related
private void showAllUserData() {
Intent validation = getActivity().getIntent();
String user_username = validation.getStringExtra("username");
String user_email = validation.getStringExtra("email");
String user_password = validation.getStringExtra("password");
String user_name = validation.getStringExtra("name");
fullNameLabel.setText(user_name);
userNameLabel.setText(user_username);
fullname.getEditText().setText.toString(user_name);
email.getEditText().setText.toString(user_email);
password.getEditText().setText.toString(user_password);
}}
My get all user data method has a problem here, in the edit text to string section, I don't how to use it in a fragment.
here is how my code looks like in android studio
Please post your code as text and not as images next time. This article contains information on how to ask a good question on StackOverflow.
Are full_name_profile, email_profile and password_profile EditTexts in your XML layout? Because in that case, the variables fullname, email and password are already EditTexts and you can just remove getEditText() from your code and set the text like this: fullname.setText(user_username)
i am creating an internet radio application for android. So far i have successfully streamed and played using the shoutcast url for various stations.This is my code :
String url = "http://185.33.22.13:7704";
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try
{
mediaPlayer.setDataSource(url);
mediaPlayer.prepare();
}
catch (IOException e)
{
e.printStackTrace();
}
mediaPlayer.start();
Next i would want to get the information of stream to be shown in my application.
I want to retrieve the information shown in green box:
People have posted about FFmpegMediaMetadataRetriever but github is way out of my league to understand also tried thier apk file which does nothing when given the above http link.Please suggest me a simple and robust solution to retrieve the data from SHOUTcast DNAS status.
Thanks in advance !
Shoutcast V1 has a special page with bitrate and other information.
If your shoutcast is running on
http://185.33.22.13:7704
then this page url will be:
http://185.33.22.13:7704/7.html
The body of that page looks like this:
<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>214,1,312,1000,213,64,Ferry Tayle - The Way Back Home (Edit) (feat. Poppy)</body></html>
Split that text by commas and you will get:
Current listeners
Stream status
Peak listeners
Maximum number of listeners (from server start)
Unique listeners
Bitrate
Song title
Here is an example in javascript (Nodejs) that gets the data from 7.html page and parses it:
var request = require('request'),
options = {
url: 'http://185.33.22.21:7704/7.html',
headers: {
'User-Agent': 'Mozilla/5.0'
}
},
regex = /<body>(.*?)<\/body>/i;
request(options, function (error, response, body) {
var match = regex.exec(body),
data = match[1].split(',');
console.log("7.html: ", body);
console.log("Current listeners: ", data[0]);
console.log("Stream status: ", data[1]);
console.log("Peak listeners: ", data[2]);
console.log("Maximum number of listeners: ", data[3]);
console.log("Unique listeners: ", data[4]);
console.log("Bitrate: ", data[5]);
console.log("Metada: ", data[6]);
});
Please note that setting "User-Agent" header is required.
If you have admin password from that server - then another way is to get XML data directly from shoutcast admin page using the following URL:
http://185.33.22.13:7704/admin.cgi?mode=viewxml
I'm trying to get a list of all applications that are capable of sending text messages.
I found several solutions on that suggest to use the PackageManager.
I think that the Intent to be used is ACTION_SEND, but when i run my code i always receive an empty List.
This is my code:
Intent mainIntent = new Intent(Intent.ACTION_SEND, null);
List<ResolveInfo> pkgAppsList = getApplicationContext().getPackageManager().queryIntentActivities( mainIntent, PackageManager.GET_RESOLVED_FILTER);
int size = pkgAppsList.size();
int i = 0;
Log.i(TAG, "Size: " + size);
for(ResolveInfo infos : pkgAppsList){
String name = infos.activityInfo.applicationInfo.loadLabel(getPackageManager()).toString();
Log.i(TAG, "name: " + name);
}
Any idea?
You haven't set the MIME type for the Intent. For example:
mainIntent.setType("text/plain");
That will produce results. However, be mindful that this won't exactly return "applications capable of sending text messages", rather those that can accept a text, not necessarily for the purpose of sending a message (as an example, the Google Translate app is capable of receving text).
Hopefully someone can help me here. I have a project that I'm doing, yes it is homework so I hope that doesn't hurt my chances of an answer here. I'm supposed to write an app that collects data from bbyopen api. Best Buys web api, it delivers details about stores in your area. Any way I've gotten a response from the server that I'm certain contains the correct information as I've displayed it in logcat using System.out.println(). However, what I would like to do is turn this string into an xml document, parse out the name of the store, it's address and then display it in a text view in a new activity.
Here is the code I'm using to parse the string and put the proper data into an array which is passed to a new activity. I'm certain that nothing is actually passed to the new activity and I'm unsure whether or not the array is even being built. Any help would be greatly appreciated.
public void callback(String serviceResult){
System.out.println(serviceResult);
try {
XmlPullParserFactory parserCreator = XmlPullParserFactory.newInstance();
parserCreator.setNamespaceAware(true);
XmlPullParser parser = parserCreator.newPullParser();
parser.setInput(new StringReader(serviceResult));
int eventType = parser.getEventType();
while (eventType != parser.END_DOCUMENT){
String name = "";
String address = "";
if ((eventType == XmlPullParser.START_TAG)&& (parser.getName().equals("longName"))){
name = parser.getName();
}
if ((eventType == XmlPullParser.START_TAG)&& (parser.getName().equals("address"))){
address = parser.getName();
Store store = new Store(name, address);
arrStore.add(store);
System.out.println(arrStore);
}
else
parser.nextTag();
}
} catch (Exception e) {
}
Intent intent = new Intent(getApplicationContext(),StoreList.class);
intent.getStringArrayListExtra(arrStore.toString(), "key");
startActivity(intent);
}
I then receive the intent in the new activity like this:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_store_list);
getIntent();
ArrayList<String> store = getIntent().getStringArrayListExtra("key");
}
However trying to do a print line on the ArrayList store, in the new activity results in a null pointer error. I suspect that is because the array is empty..?
If it helps here is what the XML that I am receiving looks like and it is being sent as a string the parser.
<stores warnings="Distances are in terms of miles (default)" currentPage="1" totalPages="1" from="1" to="4" total="4" queryTime="0.006" totalTime="0.011" >
<store>
<longName>Best Buy - Toledo II</longName>
<address>1405 Spring Meadows Dr</address>
</store>
<store>
<longName>Best Buy - Perrysburg</longName>
<address>10017 Fremont Pike</address>
</store>
<store>
<longName>Best Buy - Toledo</longName>
<address>4505 Monroe St</address>
</store>
<store>
<longName>Best Buy Mobile - Franklin Park</longName>
<address>5001 Monroe Street</address>
</store>
</stores>
The error is here:
Intent intent = new Intent(getApplicationContext(),StoreList.class);
intent.getStringArrayListExtra(arrStore.toString(), "key");
startActivity(intent);
Try: putStringArrayListExtra().
hi i would like to know how i can setup the class file to get the user input from textfields and compose an email to be sent with a button?
example would be layout with fields
I want to buy _____
I want it to be this color ____
These are my comments ____
SEND BUTTON
and it should compose an email to specific email address with subject and add the fields on the email before sending.
hope someone would have a java code for this. thanks in advance.
Fisrt you creat your custom layout and make fields for what you want then these :
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"test#lol.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"" );
this.startActivityt(Intent.createChooser(emailIntent, ""));
i am sure on the following hint.but try this using GMailservices to send the mail
int patternMailCount=0;
StringTokenizer st=new StringTokenizer(toTextField.getText().toString(),",");
while(st.hasMoreElements()){
Pattern pattern = Pattern.compile("^[A-Za-z0-9._%+\-]+#[A-Za-z0-9.\-]+\.[A-Za-z]{2,4}$");
Matcher matcher = pattern.matcher(st.nextToken().toString());
//...........
}
//ur implmentation
GMailSender sender = new GMailSender("yourgmail#gmail.com","your password");
sender.sendMail(
""+((EditText)findViewById(R.id.SUBTEXTFIELD)).getText().toString(),
emailID,toTextField.getText().toString());