• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to add button to corner going to GooglePlay store

I'm putting together a simple Android app and I wanted to add a button to one of the bottom corners of the screen that when the user presses brings them either to the specific apps GooglePlay page or my GooglePlay profile page (whichever way I decide before hand).

After doing some searching on a guide for doing this I found this link below which basically shows what I want and gives some script for doing it, the problem is I'm not exactly sure which file I need to place this script and where in it exactly, do I put this script somewhere in the AndroidManifest file ?

http://www.appsgeyser.com/blog/tag/customized-code/

Any help would be appreciated I'm new to this Android App stuff.
 
Hi gamertrail1 :D

You just want a button below to go to somewhere?

goto AndroidStudio in Designmode and put one button at bottom
the code will be displayed in your .XML file of your activity
change the properties to your needs

then you create a clicklistener in your activityfile to catch the click

Finally you need to place the Webbrowser view intern or
an intent to use the buildin webbrower of your/the users smartphone
 
Upvote 0
Someone provided me with the code to do what I want but I can't figure out part of it. Here is the code below they guy gave me.

My problem is the MainActivity.java file part, the code he gave me to put in that file I'm not sure exactly where to paste it, because no matter where I put it the app will not compile once I add that code. Any ideas ?




First, you need to add a Button to your layout which should contain the Button. In your case it's main.xml from the layout folder. Then your main.xml should look similar to this one:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!--other Views-->

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="8dp"
android:text="My Apps" />

</RelativeLayout>
In your MainActivity you assign an OnClickListener to this Button:

@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View v) {
//open up browser or play store with the provided link
String url = linkToYourDeveloperPage;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
});
}
 
Upvote 0
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View v) {
//open up browser or play store with the provided link
String url = linkToYourDeveloperPage;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
});
}

In your activitycode is a onCreate method - put it there

what error ocurred?

post complete activity code afterwards
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones