Skype application is not running - android

When I added a button it should take me to skype application to a user (name_here) .. if Skype didn't exist on my mobile, it goes to https://play.google.com/store/apps/details?id=com.skype.raider
The code is
raskypelink.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
if (uri.contains("https://www.skype.com/" )) {
String name_here = "name_here";
String uri1 = "skype://Page/" + name_here;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri1));
startActivity(intent);
} else {
String skype = "skype";
String uri1 = "https://play.google.com/store/apps/details?id=com.skype.raider" + skype;
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri1));
startActivity(i);
}
}
});
Please help!

For IF
Android Docs - http://developer.skype.com/skype-uris/skype-uri-tutorial-android
For ELSE
Change from
String uri1 = "https://play.google.com/store/apps/details?id=com.skype.raider" + skype;
to
Remove + skype
String uri1 = "https://play.google.com/store/apps/details?id=com.skype.raider";

Related

Intent does not work

On clicking the order app in the app that i have created, it calls the submitOrder() method and it is supposed to display the order summary by calling the createOrderSummary() method in gmail .However the gmail app does not open and it displays the message (which is in the else block )that I can’t display the intent.(i am new to android development.)
CheckBox whippedCreamBox = (CheckBox) findViewById(R.id.whipped_cream_check_box);
boolean isWhippedCreamBoxChecked = whippedCreamBox.isChecked();
CheckBox chocolateBox = (CheckBox) findViewById(R.id.chocalate_check_box);
boolean isChocolateBoxChecked = chocolateBox.isChecked();
int price = calculatePrice(quantity, isWhippedCreamBoxChecked, isChocolateBoxChecked);
EditText nameEditText = (EditText) findViewById(R.id.name_edit_text);
Editable userEnteredString = nameEditText.getText();
String priceMessage = createOrderSummary(userEnteredString, price, isWhippedCreamBoxChecked, isChocolateBoxChecked);
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SENDTO);
sendIntent.setData(Uri.parse("mailto:ritvikupadhyay2000#gmail.com"));
sendIntent.setType("text/plain");
sendIntent.putExtra(sendIntent.EXTRA_SUBJECT, "Order for the just java app");
sendIntent.putExtra(sendIntent.EXTRA_TEXT, priceMessage);
if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivity(sendIntent);
}
else
{
displayMessage("I can't display the intent");
}
and here is the java code for createOrderSummary()
private String createOrderSummary(Editable userEnteredString, int price, boolean isWhippedCreamBoxChecked, boolean isChocalateBoxChecked) {
String priceMessage = "Name:" + userEnteredString + "\nAdd whipped cream?" + isWhippedCreamBoxChecked + "\nAdd chocalate?" + isChocalateBoxChecked + "\nQuantity:" + quantity + "\nTotal:$" + price + "\nThank you!\n";
return priceMessage;
Try this way, it is from official docs.
And also note to use String array, many claims using String array only works.
public void composeEmail(String[] addresses, String subject) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_EMAIL, addresses);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}

Open URL followed by second URL

I need to open the URL followed by another in order to remove the previous URL for viewing. The action is required in-lieu of closing the browser tab.
The first URL is opening and the second one is no where to be seen. Where I am going wrong?
Uri uri = Uri.parse(URL_STRING);
//modified the URL_STRING for security
URL_STRING = "https://myserver.com/action";
final Intent intent1 = new Intent(Intent.ACTION_VIEW, uri);
intent1.putExtra(Browser.EXTRA_APPLICATION_ID, "toto");
startActivity(intent1);
//SystemClock.sleep(1000);
String POST_URL = "http://www.google.com";
uri = Uri.parse(POST_URL);
final Intent intent2 = new Intent(Intent.ACTION_VIEW, uri);
intent2.putExtra(Browser.EXTRA_APPLICATION_ID, "toto");
Have even tried to put a sleep with varying values. Did not work.
Follow this to load two URls in the external browser.
Declare these variables as global variables.
int count = 0;
Runnable runnable=null;
Handler handler = new Handler();
Then call this method to load the Url in browser.
public void goToBrowser() {
final Uri[] uri = new Uri[1];
runnable = new Runnable() {
public void run() {
switch (count) {
case 0:
String URL_STRING = "https://myserver.com/action";
uri[0] = Uri.parse(URL_STRING);
//modified the URL_STRING for security
final Intent intent1 = new Intent(Intent.ACTION_VIEW, uri[0]);
intent1.putExtra(Browser.EXTRA_APPLICATION_ID, "toto");
startActivity(intent1);
break;
case 1:
String POST_URL = "http://www.google.com";
uri[0] = Uri.parse(POST_URL);
final Intent intent2 = new Intent(Intent.ACTION_VIEW, uri[0]);
intent2.putExtra(Browser.EXTRA_APPLICATION_ID, "toto");
startActivity(intent2);
break;
}
if (count++ <= 1){
handler.postDelayed(this, 1000);
}else {
handler.removeCallbacks(runnable);
}
}
};
handler.post(runnable);
}

I want to write Number sign in string of android

hi guys i am making an app in which when user click on button it will redirect them to phone app of android with *700# entered. but the problem is when i write # in string it doesn't appear in phone app of android.
here is the code:
public void activite (View view) {
String number = "*700#";
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" +number));
startActivity(intent);
}
it works fine except that number sign doesn't come up please help.
Try this method,
private Uri getCallString(String ussd) {
String uriString = "";
if(!ussd.startsWith("tel:"))
uriString += "tel:";
for(char c : ussd.toCharArray()) {
if(c == '#')
uriString += Uri.encode("#");
else
uriString += c;
}
return Uri.parse(uriString);
}
To call it,
String number = "*700#";
Intent intent = new Intent(Intent.ACTION_CALL, getCallString(number));
startActivity(intent);
See this SO thread.
Try out this:
public void activite (View view) {
String encodedHash = Uri.encode("#"); //encode hash here
String number = "*700";
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" +number+encodedHash)); //updated here
startActivity(intent);
}
public void activite (View view) {
String number = "*700";
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + Uri.encode( number + "#")));
startActivity(intent);
}
this is how it works for me. THANK YOU GUYS FOR REPLYING MY QUERY!

Android share text and image on linkedIn using intent

Here I'm trying to send image with text on LinkedIn as post as:
Intent linkedinIntent;
String text1 = "...kaLis...";
linkedinIntent = new Intent(Intent.ACTION_SEND);
Uri path = Uri.parse(MediaStore.Images.Media.insertImage(activity.getContentResolver(),
BitmapFactory.decodeResource(activity.getResources(), R.drawable.logo), null, null));
linkedinIntent.putExtra(Intent.EXTRA_STREAM, path);
linkedinIntent.putExtra(Intent.EXTRA_TEXT, text1);
linkedinIntent.setType("image/*");
// linkedinIntent.setType("text/plain");
boolean linkedinAppFound = false;
List<ResolveInfo> matches2 = activity.getPackageManager()
.queryIntentActivities(linkedinIntent, 0);
for (ResolveInfo info : matches2) {
if (info.activityInfo.packageName.toLowerCase().startsWith(
"com.linkedin")) {
linkedinIntent.setPackage(info.activityInfo.packageName);
linkedinAppFound = true;
break;
}
}
if (linkedinAppFound) {
activity.startActivity(linkedinIntent);
} else {
Toast.makeText(activity, "LinkedIn app not Insatlled in your mobile", Toast.LENGTH_SHORT).show();
}
But this code is enable to send only a thing at a time.

Use application to rate it on market [duplicate]

This question already has answers here:
"Rate This App"-link in Google Play store app on the phone
(21 answers)
Closed 2 years ago.
I am currently developing an application in Android Where I want to give some functionality to user to rate the current application.
Their will be a button on it's click it will ask ask whether user want to rate the application or not? If yes will will go to market application on device to rate application
(Market should show this application.) or it will open browser which will load market & showing this application.
Any one used this kind of functionality before. Please provide some help.
Thank You.
I always use a method like this one:
private void launchMarket() {
Uri uri = Uri.parse("market://details?id=" + getPackageName());
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
try {
startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, R.string.couldnt_launch_market, Toast.LENGTH_LONG).show();
}
}
public class AppRater {
private final static String APP_TITLE = "App Name";// App Name
private final static String APP_PNAME = "com.example.name";// Package Name
private final static int DAYS_UNTIL_PROMPT = 3;//Min number of days
private final static int LAUNCHES_UNTIL_PROMPT = 3;//Min number of launches
public static void app_launched(Context mContext) {
SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0);
if (prefs.getBoolean("dontshowagain", false)) { return ; }
SharedPreferences.Editor editor = prefs.edit();
// Increment launch counter
long launch_count = prefs.getLong("launch_count", 0) + 1;
editor.putLong("launch_count", launch_count);
// Get date of first launch
Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0);
if (date_firstLaunch == 0) {
date_firstLaunch = System.currentTimeMillis();
editor.putLong("date_firstlaunch", date_firstLaunch);
}
// Wait at least n days before opening
if (launch_count >= LAUNCHES_UNTIL_PROMPT) {
if (System.currentTimeMillis() >= date_firstLaunch +
(DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000)) {
showRateDialog(mContext, editor);
}
}
editor.commit();
}
public static void showRateDialog(final Context mContext, final SharedPreferences.Editor editor) {
final Dialog dialog = new Dialog(mContext);
dialog.setTitle("Rate " + APP_TITLE);
LinearLayout ll = new LinearLayout(mContext);
ll.setOrientation(LinearLayout.VERTICAL);
TextView tv = new TextView(mContext);
tv.setText("If you enjoy using " + APP_TITLE + ", please take a moment to rate it. Thanks for your support!");
tv.setWidth(240);
tv.setPadding(4, 0, 4, 10);
ll.addView(tv);
Button b1 = new Button(mContext);
b1.setText("Rate " + APP_TITLE);
b1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
dialog.dismiss();
}
});
ll.addView(b1);
Button b2 = new Button(mContext);
b2.setText("Remind me later");
b2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
ll.addView(b2);
Button b3 = new Button(mContext);
b3.setText("No, thanks");
b3.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (editor != null) {
editor.putBoolean("dontshowagain", true);
editor.commit();
}
dialog.dismiss();
}
});
ll.addView(b3);
dialog.setContentView(ll);
dialog.show();
}}
Now Integrate class to your activity like this ->
AppRater.app_launched(this);
Here is simple solution for :
final String appPackageName = "com.name.app";
private void launchMyMarket() {
Uri uri = Uri.parse("market://details?id=" + getPackageName());
Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri);
try {
startActivity(myAppLinkToMarket);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, " unable to find source market app! try again", Toast.LENGTH_LONG).show();
}
}
The answers here won't take you directly to playstore if you have multiple market apps on your phone. Instead it will show a picker dialog.
To open playstore directly, use this:
private fun rateUs() {
val uri = Uri.parse("https://play.google.com/store/apps/details?id=" + activity?.packageName.toString() + "")
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}

Categories

Resources