zoukankan      html  css  js  c++  java
  • 一手遮天 Android

    项目地址 https://github.com/webabcd/AndroidDemo
    作者 webabcd

    一手遮天 Android - ipc(跨进程通信): 分享

    示例如下:

    /ipc/ShareSourceDemo1.java

    /**
     * 本例用于演示“分享源”
     *
     * 注:
     * 1、关于“分享目标”请参见 AndroidDemoIpc 项目中的 ShareTargetDemo1.java
     */
    
    package com.webabcd.androiddemo.ipc;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.Button;
    
    import com.webabcd.androiddemo.R;
    
    public class ShareSourceDemo1 extends AppCompatActivity {
    
        private Button mButton1;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_ipc_sharesourcedemo1);
    
            mButton1 = findViewById(R.id.button1);
    
            sample();
        }
    
        private void sample() {
            Intent intent = new Intent();
            // 设置 action 为发送分享
            intent.setAction(Intent.ACTION_SEND);
            // 设置 type 为发送纯文本内容
            intent.setType("text/plain");
            // 设置需要分享的数据
            intent.putExtra(Intent.EXTRA_TEXT, "我是分享内容");
    
            // 弹出系统分享
            startActivity(Intent.createChooser(intent, "系统分享框的 Title 上显示的信息"));
            // startActivity(Intent.createChooser(intent, getResources().getText(R.string.app_name)));
        }
    }
    

    /layout/activity_ipc_sharesourcedemo1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="分享文本数据" />
    
    </LinearLayout>
    

    项目地址 https://github.com/webabcd/AndroidDemo
    作者 webabcd

  • 相关阅读:
    单调队列 POJ 2823
    大组合数取mod lucas 定理
    多校4
    多校2
    2016多校1
    百度之星 初赛B续
    iot-web增加apis-namespace组件
    25.75k8s
    新项目增加gradlew
    vue图片点击放大预览v-viewer
  • 原文地址:https://www.cnblogs.com/webabcd/p/android_ipc_ShareSourceDemo1.html
Copyright © 2011-2022 走看看