Skip to main content

Redirect to any link from android app with source code

Hello guys, In this tutorial, we are going to tell you that how can you redirect to any link or how can you access any link from your own Android app with source code.
Please follow the below steps:
Here we are going to upload the data and files to Google drive and going to access those data through our app.

Step 1: Refer to this video for uploading data on your Google drive.


Step 2: After uploading data to google drive, now we are going to access all these files from our android application.

Step 3:  Now create the new android project in the android studio. To create a new project, please visit the link given below:

http://scubecodeclub.blogspot.com/2018/09/add-long-text-description-paragraph-in.html

Step 4: You can refer or paste the code given below in your project.

MainActivity.java:

package com.sharayusuryawanshi.lenovo.link_redirection;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

    Button
ol;

   
@Override
   
protected void onCreate(Bundle savedInstanceState) {
       
super.onCreate(savedInstanceState);
        setContentView(R.layout.
activity_main);
       
ol = (Button) findViewById(R.id.openlink);

      
ol.setOnClickListener(new View.OnClickListener() {
          
@Override
          
public void onClick(View view) {
              Intent i=
new Intent("android.intent.action.VIEW",Uri.parse("https://drive.google.com/drive/u/0/my-drive?ogsrc=32"));
               startActivity(i);
           }
       });
    }

}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_balasana"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.sharayusuryawanshi.lenovo.link_redirection.MainActivity">
  <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
 <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
 </RelativeLayout>
<Button
      android:id="@+id/openlink" 
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="Open Link"
      android:textColor="#000"/>
 </ScrollView>
</RelativeLayout>
Output for this code will be like this:









Comments