home top ad

how to make my android app appear in the share list of another specific app

Hello Guys, in this tutorial we will learn how to make my android app appear in the sharing list of another specific app.
Whenever we make our app, if we want to show a link or image from another app in our app, then we have to show our app in the stock list, which automatically opens our app and links any video or photo we send from other apps It just started appearing in our app.
Today we will tell you three rules, so that you can solve this problem easily.

Step 1. Start a New Android Project
first Start building a new Android project in Android studio. Choose File again New, select "New Project" and then click "Next". In the New Android Application window, enter your chosen application, project, and package names and select "Next" and finish at the end.
After creating the project, you will see two files, first activity_main and second MainActivity.java, then you have to paste the code given below activity_main and MainActivity.java.

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:layout_width="match_parent"  
   android:layout_height="match_parent"  
   tools:context=".MainActivity">  
   <TextView  
     android:id="@+id/text"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:text="Hello World!"  
     android:layout_centerInParent="true"  
     android:textColor="@color/purple_700"  
     android:textSize="15sp"/>  
   <ImageView  
     android:id="@+id/picture"  
     android:layout_width="match_parent"  
     android:layout_height="match_parent"  
     android:contentDescription="Receive Picture"/>  
 </RelativeLayout>  
MainActivity.java
 import androidx.appcompat.app.AppCompatActivity;  
 import android.content.Intent;  
 import android.net.Uri;  
 import android.os.Bundle;  
 import android.util.Log;  
 import android.view.View;  
 import android.widget.ImageView;  
 import android.widget.TextView;  
 public class MainActivity extends AppCompatActivity {  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_main);  
     shareList();  
   }  
   private void shareList() {  
     Intent intent=getIntent();  
     String recieve=intent.getAction();  
     String type=intent.getType();  
     if (recieve.equals(Intent.ACTION_SEND))  
     {  
       if (type.startsWith("text/"))  
       {  
         String text=intent.getStringExtra(Intent.EXTRA_TEXT);  
         if (text!=null){  
           receiveText.setText(text);  
          picture.setVisibility(View.GONE);  
         }  
       }  
       else if (type.startsWith("image/")){  
         Uri uri=(Uri)intent.getParcelableExtra(Intent.EXTRA_STREAM);  
         Uri file;  
         if (uri!=null){  
           file=uri;  
           receiveText.setVisibility(View.GONE);  
           picture.setImageURI(uri);  
         }  
       }  
     }else if (intent.equals(Intent.ACTION_MAIN))  
     {  
     }  
   }  
 }  
Now enter the code below in the expression.

This is also useful for you

  • How to Create Image Slider using ViewPager in android studio
  • How to create Swipeable Videos Like TikTok Using ViewPager2 in andriod studio
  • how to get all audio files in android programmatically
  • How to use SearchView in andriod studio
  • How to check internet Connection in androd studio
  • How to Create Bottom Sheet in android studio
  • How to Refresh a list Using RecyclerView in Android Studio
  • How to create Welcome Splash Screen with animation in android studio
  • How to create menu and sub menu in android studio
  • How to create a list item with RecyclerView in Android Studio
  • BottomNavigationView android example
  • How to create Text to Speech app in android studio
  •  <?xml version="1.0" encoding="utf-8"?>  
     <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
       package="com.example.sharelistproject">  
       <application  
         android:allowBackup="true"  
         android:icon="@mipmap/ic_launcher"  
         android:label="@string/app_name"  
         android:roundIcon="@mipmap/ic_launcher_round"  
         android:supportsRtl="true"  
         android:theme="@style/Theme.ShareListProject">  
         <activity android:name=".MainActivity">  
           <intent-filter>  
             <action android:name="android.intent.action.MAIN" />  
             <category android:name="android.intent.category.LAUNCHER" />  
           </intent-filter>  
           <intent-filter>  
             <action android:name="android.intent.action.SEND" />  
             <category android:name="android.intent.category.DEFAULT" />  
             <data android:mimeType="image/*" />  
             <data android:mimeType="text/*" />  
           </intent-filter>  
         </activity>  
       </application>  
     </manifest>  
    
    Step 2.This way, you do not have to do anything else, instead of the ShareList method in MainActivity, you will have to create a new method that will be different from the shareList method.
    MainActivity.java
     package com.avdigits.sharelistproject;  
     import androidx.appcompat.app.AppCompatActivity;  
     import android.content.Intent;  
     import android.net.Uri;  
     import android.os.Bundle;  
     import android.util.Log;  
     import android.view.View;  
     import android.widget.ImageView;  
     import android.widget.TextView;  
     public class MainActivity extends AppCompatActivity {  
      private TextView receiveText;  
      private ImageView picture;  
       @Override  
       protected void onCreate(Bundle savedInstanceState) {  
         super.onCreate(savedInstanceState);  
         setContentView(R.layout.activity_main);  
         appList();  
       }  
       private void appList() {  
         Intent intent=getIntent();  
         String reciece=intent.getAction();  
         String type=intent.getType();  
         if ("android.intent.action.SEND".equals(reciece)&& type !=null &&"text/plain".equals(type)){  
           Log.println(Log.ASSERT,"shareText",intent.getStringExtra("android.intent.extra.TEXT"));  
         }  
       }  Mainfest
    
    And the display will be slightly different from the previous one
    Mainfest
     <?xml version="1.0" encoding="utf-8"?>  
     <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
       package="com.avdigits.sharelistproject">  
       <application  
         android:allowBackup="true"  
         android:icon="@mipmap/ic_launcher"  
         android:label="@string/app_name"  
         android:roundIcon="@mipmap/ic_launcher_round"  
         android:supportsRtl="true"  
         android:theme="@style/Theme.ShareListProject">  
         <activity android:name=".MainActivity">  
           <intent-filter>  
             <action android:name="android.intent.action.MAIN" />  
             <category android:name="android.intent.category.LAUNCHER" />  
           </intent-filter>  
           <intent-filter>  
             <action android:name="android.intent.action.SEND" />  
             <category android:name="android.intent.category.DEFAULT" />  
            <data android:mimeType="text/plain"/>  
           </intent-filter>  
         </activity>  
       </application>  
     </manifest>  
    
    A screenshot is given below so that you can see how the share method will work. This ScreenShot share image link:
    Here show Receive link on TextView
    Here Share Image
    Here Show Receive Image on ImageVIew
    hope that this article will be very useful for you.
    Thank you...

Post a Comment

0 Comments