一区二区日本_久久久久久久国产精品_无码国模国产在线观看_久久99深爱久久99精品_亚洲一区二区三区四区五区午夜_日本在线观看一区二区

Android Share App Data (ACTION_SEND)含代碼

Android Share App Data (ACTION_SEND)

Android使用 ACTION_SEND 事件來發(fā)送數(shù)據(jù),其屬于 android.content.Intent 類,可以將數(shù)據(jù)從一個(gè)活動(dòng)發(fā)送到另一個(gè)活動(dòng)以及從當(dāng)前活動(dòng)發(fā)送到應(yīng)用程序外部。愛掏網(wǎng) - it200.comIntent類需要指定要共享的數(shù)據(jù)及其類型。愛掏網(wǎng) - it200.com

通常情況下,ACTION_SEND操作會(huì)發(fā)送內(nèi)置瀏覽器應(yīng)用程序的URL。愛掏網(wǎng) - it200.com在共享數(shù)據(jù)時(shí),Intent調(diào)用createChooser()方法,該方法接收Intent對象并指定選擇器對話框的標(biāo)題。愛掏網(wǎng) - it200.com Intent.createChooser()方法用于顯示選擇器。愛掏網(wǎng) - it200.com

ACTION_SEND示例

在此示例中,我們將共享純文本,即瀏覽器的URL鏈接。愛掏網(wǎng) - it200.com

activity_main.xml

文件: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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.test.shareapp.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:id="@+id/textView" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Share App"
        android:id="@+id/button"
        android:layout_marginBottom="95dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

Activity類

文件:MainActivity.java

package com.example.test.shareapp;

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

public class MainActivity extends AppCompatActivity {
Button sharebutton;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        sharebutton=(Button)findViewById(R.id.button);
        sharebutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent shareIntent =   new Intent(android.content.Intent.ACTION_SEND);
                shareIntent.setType("text/plain");
                shareIntent.putExtra(Intent.EXTRA_SUBJECT,"Insert Subject here");
                String app_url = " https://play.google.com/store/apps/details?id=my.example.javatpoint";
                shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,app_url);
                startActivity(Intent.createChooser(shareIntent, "Share via"));
            }
        });
    }
}

輸出

聲明:所有內(nèi)容來自互聯(lián)網(wǎng)搜索結(jié)果,不保證100%準(zhǔn)確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。
發(fā)表評論
更多 網(wǎng)友評論0 條評論)
暫無評論

返回頂部

主站蜘蛛池模板: 国产在线一区二 | 精品久久久久国产免费第一页 | 国内精品在线视频 | 久久99精品久久久久久 | 亚洲视频欧美视频 | 不卡一区| 久久国产精品-国产精品 | 中文在线观看视频 | 日韩中文字幕第一页 | 我要看一级片 | 国产精品96久久久久久 | 国产一区免费视频 | 欧美va大片 | 欧美在线a | 欧美一区二区在线观看 | 国产精品明星裸体写真集 | 91影视 | 伊伊综合网 | 国产成人精品999在线观看 | 久久草在线视频 | 成人免费三级电影 | 91视频在线 | 99精品在线免费观看 | 国产美女黄色 | 在线视频久久 | 99精品国产在热久久 | 天堂素人约啪 | 国产日产精品一区二区三区四区 | 国产精品毛片一区二区三区 | 国产精品久久久久久福利一牛影视 | av黄色免费在线观看 | 夜夜精品视频 | 国产91在线 | 欧美 | 国产片网站 | 国产免费一区二区三区 | 欧美在线一区二区视频 | 国产传媒在线播放 | 天天操夜夜拍 | 欧美黄色一区 | 精品丝袜在线 | 欧美精品福利 |