Quantcast
Channel: Kyogs
Viewing all articles
Browse latest Browse all 18

Copy and share your useful data from Google chrome browser to your application in android.

$
0
0


Here In this blog I explain that how to copy and share your useful data from chrome browser in android.

1) How to show your application in Google chrome share list ?

First in manifest.xml file you need intent-filter to show your application in share list which will be display on click of share button in Google chrome in your android device.

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleInstance">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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



Show your application in share list.(Here Blog detail)



 2) How to receive this data in activity ?
 
  Here I am display this data in DiaolgActivity So,we need to set intent-filter in manifest.xml file as show below .

    <activity
        android:name=".DiaolgActivity"
        android:label="@string/app_name"
        android:theme="@style/AppThemeDialog"
        android:launchMode="singleInstance">
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <action android:name="com.google.android.gm.action.AUTO_SEND" />

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

            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity>

In Oncreate() Method do this thing.

    if (Intent.ACTION_SEND.equals(action) && type != null) {
            if ("text/plain".equals(type)) {
               String strData = intent.getStringExtra(Intent.EXTRA_TEXT);// here get data.
                Log.e("text", "- " + strData );
            } else {
                finish();
            }
        }




On Save click you can store this data in your application.


Viewing all articles
Browse latest Browse all 18

Trending Articles