Android about button to rate on market - android

I am little confused with this code am looking for somenthing similar i have a button that i want it to say rate and when click it takes you to the android market where the user can rate my application, please help
Button bRate = (Button) findViewById(R.id.button7);
bRate.setOnClickListener(new View.OnClickListener() {
//plus the code on the top here is my idea of the code
}
Elipse is saying something is wrong and I understand that iI need to put my market link but the button still doesn't work
I couldn't post it on the same page here is the link for the original question
Use application to rate it on market

You have just add your app package name...
https://play.google.com/store/apps/details?id=your packagename
And call using Intent.ACTION_VIEW
String str ="https://play.google.com/store/apps/details?id=com.zeustechnocrats.quickfoods";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));

This was helpful for me to do the same thing using an image button. here the code I used.
final ImageButton mybutton = (ImageButton) findViewById(R.id.imageButton);
mybutton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String str ="https://play.google.com/store/apps/details?id=ws.crandell.newspaperpuzzles";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
}
});

Example code you can use.
Change your_package_name to your.package.name. E.g. com.example.myapp
Java File:
public void ratebutton(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW)
.setData(Uri
.parse("https://play.google.com/store/apps/details?id=your_package_name"));
startActivity(intent);
}
Layout file:
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="ratebutton"
android:text="#string/rate"
android:layout_gravity="center_horizontal" />
strings.xml:
<string name="rate">Rate with 5 stars please</string>

Related

Is there a way to get information from the web browser in Android?

I would like to create a charity application where if the users were to press the 'Donate' button, their browser would open up a link to a 3rd-party crowdfunding website where they would donate some amount for that project (or choose to exit the app or whatever!). How do I get to know what amount they have donated (or not!) from the browser so that this data can be used for that member's stats, etc.
Yes it is possible. You can use webView
Button button = (Button) findViewById(R.id.b);
button.setOnClickListener(new View.OnClickLister()
#overide
public void onClick(View v) {
WebView mWebView=(WebView)_findViewById(R.id.webView);
mWebview .loadUrl("url for third party app");
setContentView(mWebview );
});
or you can use intent
Button button = (Button) findViewById(R.id.b);
button.setOnClickListener(new View.OnClickLister()
#overide
public void onClick(View v) {
WString url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
});

Using an intent to forward users to twitter app with pre-determiend search keyword

I want to be able to switch between my app and twitters app to show a search for a pre-determined hashtag.
I have an on click listener & sending the user to the twitter app... loading the tweets and allowing the discussion of that hashtag. There is the logic but how can I do this? What I get now is just my feed and a drop down list of previous searches.
Here is the listener & intent code:
final Button button = (Button) view.findViewById(R.id.C_Twitter_Button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("twitter://search?f=realtime&q=%23KeyWord"));
startActivity(intent);
}catch (Exception e) {
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("https://twitter.com/search?f=realtime&q=%23KeyWord")));
}
}
});
Can anyone offer me a solution?
Thanks
The search query was wrong :(
The solution is to use the following url to search the twitter app:
twitter://search?query=%23hashtag
Cheers

(Android-Eclipse)Duplicate method onClick(View) error in .java archive while inserting a 3rd button

I had two buttons working great when I tried to import a third one into my archive AboutScreen.java which is related to a .xml file located to the android/layout.
When I inserted the third one the error message was : "Duplicate method onClick(View) in type new View.OnClickListener(){}"
My third button's id is : button_contact_info.Do you have any idea why I have this error?
mStartButton = (Button) findViewById(R.id.button_start);
nextButton = (Button) findViewById(R.id.nextButton);
button_contact_info = (Button) findViewById(R.id.button_contact_info);
mStartButton.setOnClickListener(this);
nextButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent myintent2 = new Intent(AboutScreen.this,
Museum_info.class);
startActivity(myintent2);
}
});
// Intent gia to Museum_Contact_Info.class
button_contact_info.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent myintent3 = new Intent(AboutScreen.this,
Museum_Contact_Info.class);
startActivity(myintent3);
}
});
I don't think there is any problem you have in your code. Just try to clean your project and run it again. Might be the button's id that you are generating is not updated in R.java file that's why you are getting error.
Still if you face any error then please post your log-cat as well as whole code in question.

Open link on Button

i'm still new and totally noob so please carry on with me .
how to open a link when button clicked in android?
one.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
}
});
Edit: i'm using phonegap plugin . thanks
Write this code inside onClick :
Uri uri = Uri.parse("http://www.google.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Also add the following line to your manifest.xml because you need to have Internet permission to actually use the internet :
<uses-permission android:name="android.permission.INTERNET" />
Read more about Android Permissions.
To read more about Uri refer this link. Also read how Intents work in Android.
Since you are using PhoneGap, un-comment either of the methods below:
one.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
//super.loadUrl("www.google.com");
// or
//loadUril("www.google.com");
}
});

Android: Image button as a hyperlink, phone call, map directions?

I have a simple app that I'm putting together for my company. I have 4 buttons that I've created but can't seem to get them to link correctly. One button should open our mobile site, another button to call us, another button to map to us, and the final button linked to our "News" site. Any help would be greatly appreciated!
On your buttons, you should set OnClickListener, and to do some required actions you could see the example below:
To Open a Map with Certain Location
mapButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + your-location-geo-address));
startActivity(i);
}
});
To call certain number
callButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + telephone-number));
startActivity(i);
}
});
To open a website
linkButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(website-address));
startActivity(i);
}
});
Change "location-address", "telephone-number", and "website-address" with your own String value.
I hope this helps.
anmustangs answer is very good, but one thing I would like to add for the button you are making for a link to your site, where anmustangs wrote (website-address) instead of just typing in a site, it needs to put formatted correctly. For example, you can use "http://www.google.com" and yes you do need to use the quotation marks I put in there. I know I am years late to this thread but who knows who my post may help.

Categories

Resources