Share text to app inventor

2

I have been researching, because I need to share text to an app created with inventor app.

I do not need a button to have my app and it can share, this is how it is done.

I need the opposite (for example, my app appears in chrome) and when I click, the app will open with what was shared.

clarification / example: we are in Google Chrome and we want to share the link from the options. and we get: whatsapp, facebook, ... so that my app also appears. and clearly that my app captures what is sent to it.

manifest:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="appinventor.ai_quique81.cutout" platformBuildVersionCode="22" platformBuildVersionName="5.1.1-1819727">
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <application android:debuggable="false" android:icon="@drawable/ya" android:label="cutout" android:name="com.google.appinventor.components.runtime.multidex.MultiDexApplication">
        <activity android:configChanges="keyboard|keyboardHidden|orientation" android:name=".Screen1" android:windowSoftInputMode="stateHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name=".YourActivity" >
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain" />
    </intent-filter>
</activity>
        <activity android:configChanges="keyboard|keyboardHidden|orientation" android:name="appinventor.ai_quique81.cutout.Screen2" android:windowSoftInputMode="stateHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
            </intent-filter>
        </activity>
    </application>
</manifest>
    
asked by Enrique Ballester Gómez 31.08.2016 в 08:24
source

2 answers

2

For an application to appear in the list of shared options you must use intent-filter .

Some examples here and here .

In summary mode, in your manifest define ( documentation ):

<activity android:name=".YourActivity" >
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain" />
    </intent-filter>
</activity>

Within intent-filter we have 3 attributes:

  • action : In your case SEND to receive.
  • category : Important that DEFAULT
  • data android : Type of data that you receive, in this case plain text. It could be image/* to accept all kinds of images.
answered by 31.08.2016 в 15:56
1

All Android applications have a Manifest file, if you do not do it manually, it is created automatically, I have not used App Inventor to create apps but you can try what I propose.

My proposal:

1.- Download Apktool, is an application for engineering invera to apk's. files. You can do it from here, follow a series of steps for installation that are very simple.

2.- You need to have installed the Java JDK, download from here.

3.- Need to have installed the Android SDK, download from here

4.- Have framework-res.apk, (you can find it in /system/framework/framework-res.apk).

5.- You have the apk (In this case it would be your appInventor app)

When you have that ready, locate yourself in the folder of the apk and write the following in the console to decompile the apk:

apktool d -s nombre_de_tu_app.apk

With this you create a folder with the same name as your app, you enter the folder and you will see a directory similar to this:

--TuApp
     ---Assets
     ---Original
     ---res
     ---smali
     ---AndroidManifest.xml

. . .

Then, you open the file called AndroidManifest.xml , which will look similar to this:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="appinventor.ai_mletsch80.AppInvActivityStarter">
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  . . .

            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
           .......
        </activity>
       . . .

            <intent-filter>
                <action android:name="android.provider.Telephony.SMS_RECEIVED"/>
                <action android:name="com.google.android.apps.googlevoice.SMS_RECEIVED" android:permission="com.google.android.apps.googlevoice.permission.RECEIVE_SMS"/>
            </intent-filter>
        </receiver>
    </application>
</manifest>

There you put the lines of code that are presented to you in the other answer:

<activity android:name=".YourActivity" >
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain" />
    </intent-filter>
</activity>

After having made your changes it is only necessary to recompile your app, with the following:

apktool b nombre_de_tu_app

Note:

name_of_your_app is the name of your app, you should not put the extension apk or you will mark error.

EDITING

At the end your Manifest file should look something like this (Adding the lines under your launcher activity):

 <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
<!-- Aquí por debajo de MAIN y LAUNCHER ya agregas las líneas -->
       <intent-filter>
            <action android:name="android.intent.action.SEND" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="image/*" />
        </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>

        <intent-filter>
            <action android:name="android.intent.action.SEND_MULTIPLE" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="image/*" />

That would be it, if you want to learn and know more about the decompilation and recompilation of apks you can visit this site (in English) and this other (in Spanish)

    
answered by 01.09.2016 в 19:46