中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

哪個網(wǎng)站可以免費(fèi)看小說不收費(fèi)百度網(wǎng)絡(luò)營銷推廣

哪個網(wǎng)站可以免費(fèi)看小說不收費(fèi),百度網(wǎng)絡(luò)營銷推廣,php 網(wǎng)站開發(fā)收費(fèi),工程網(wǎng)站建設(shè)什么是 Android 系統(tǒng)的原生分享呢,如下圖所示 創(chuàng)建一個 Intent ,指定其 Action 為 Intent.ACTION_SEND,這表示要創(chuàng)建一個發(fā)送指定內(nèi)容的行動。 Intent sendIntent new Intent(); sendIntent.setAction(Intent.ACTION_SEND); 指定需要發(fā)送的…

什么是 Android 系統(tǒng)的原生分享呢,如下圖所示

創(chuàng)建一個 Intent ,指定其 Action 為 Intent.ACTION_SEND,這表示要創(chuàng)建一個發(fā)送指定內(nèi)容的行動。

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);

?指定需要發(fā)送的內(nèi)容和類型。

// 比如發(fā)送文本形式的數(shù)據(jù)內(nèi)容
// 指定發(fā)送的內(nèi)容
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text");
// 指定發(fā)送內(nèi)容的類型
sendIntent.setType("text/plain"); 
// 比如發(fā)送二進(jìn)制文件數(shù)據(jù)流內(nèi)容(比如圖片、視頻、音頻文件等等)
// 指定發(fā)送的內(nèi)容 (EXTRA_STREAM 對于文件 Uri )
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
// 指定發(fā)送內(nèi)容的類型 (MIME type)
shareIntent.setType("image/jpeg");

向系統(tǒng)發(fā)送Activity,打開系統(tǒng)分享選擇器,出現(xiàn)如上圖所示界面。?

startActivity(Intent.createChooser(shareIntent, "Share"));

完整代碼如下:


// 原生通用分享文本
public void shareText(String title, String text){Intent sendIntent = new Intent();sendIntent.setAction(Intent.ACTION_SEND);if (title.isEmpty()){title = "share";}sendIntent.putExtra(Intent.EXTRA_TEXT, text);sendIntent.setType("text/plain");startActivityForResult(Intent.createChooser(sendIntent, title), 80001);
}// 原生通用分享圖片
public void shareImage(String title, String filePath){Intent sendIntent = new Intent();sendIntent.setAction(Intent.ACTION_SEND);if (title.isEmpty()){title = "share";}File file = new File(filePath);Uri uri = getFileUri(this, file);sendIntent.putExtra(Intent.EXTRA_STREAM, uri);sendIntent.setType("image/png");startActivityForResult(Intent.createChooser(sendIntent, title), 80002);
}public Uri getFileUri(Context context, File file){Uri uri;// 低版本直接用 Uri.fromFileif (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {uri = Uri.fromFile(file);}else {try {uri = FileProvider.getUriForFile(this, getPackageName0() + ".fileProvider", file);} catch (Exception e) {e.printStackTrace();uri = getImageContentUri(context, file);}if (uri == null) {uri = getImageContentUri(context, file);}}return uri;
}public Uri getImageContentUri(Context context, File imageFile) {String filePath = imageFile.getAbsolutePath();Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,new String[] { MediaStore.Images.Media._ID }, MediaStore.Images.Media.DATA + "=? ",new String[] { filePath }, null);if (cursor != null && cursor.moveToFirst()) {int id = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));Uri baseUri = Uri.parse("content://media/external/images/media");return Uri.withAppendedPath(baseUri, "" + id);} else {if (imageFile.exists()) {ContentValues values = new ContentValues();values.put(MediaStore.Images.Media.DATA, filePath);return context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);} else {return null;}}
}

如果要分享到指定的app呢?


// 特定App 分享文本
public void shareTextByApp(String pkgName, String appName, String title, String text){if (!checkAppInstalled(this, pkgName)){Toast.makeText(getApplicationContext(), "You need install the " + appName + " first", Toast.LENGTH_LONG).show();return;}if (title.isEmpty()){title = "share";}Intent sendIntent = new Intent();sendIntent.setAction(Intent.ACTION_SEND);sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);sendIntent.putExtra(Intent.EXTRA_TEXT, text);sendIntent.setType("text/plain");sendIntent.setPackage(pkgName);startActivity(sendIntent);
}// 特定App 分享文本
public void shareImageByApp(String pkgName, String appName, String title, String filePath){if (!checkAppInstalled(this, pkgName)){Toast.makeText(getApplicationContext(), "You need install the " + appName + " first", Toast.LENGTH_LONG).show();return;}if (title.isEmpty()){title = "share";}Intent sendIntent = new Intent();sendIntent.setAction(Intent.ACTION_SEND);sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);File file = new File(filePath);Uri uri = getFileUri(this, file);sendIntent.putExtra(Intent.EXTRA_STREAM, uri);sendIntent.setType("image/png");sendIntent.setPackage(pkgName);startActivity(sendIntent);
}// 是否安裝某app
public boolean checkAppInstalled(Context context, String pkgName) {try {context.getPackageManager().getPackageInfo(pkgName, 0);} catch (Exception x) {return false;}return true;
}
//例如 WhatsApp 的分享
shareTextByApp("com.whatsapp", "WhatsApp", title, content);//Facebook 的分享
shareImageByApp("com.facebook.katana", "Facebook", title, filePath);

http://www.risenshineclean.com/news/40931.html

相關(guān)文章:

  • 寧波網(wǎng)站建設(shè)模板下載免費(fèi)宣傳軟文模板
  • 萬戶網(wǎng)絡(luò)網(wǎng)站建設(shè)軟文營銷的經(jīng)典案例
  • 網(wǎng)站建設(shè)方案書 備案最近發(fā)生的熱點(diǎn)新聞事件
  • 大型門戶網(wǎng)站建設(shè)一般多少錢北京云無限優(yōu)化
  • 武漢建設(shè)局網(wǎng)站南寧百度seo排名公司
  • 深圳網(wǎng)站設(shè)計(jì)興田德潤放心百度關(guān)鍵詞優(yōu)化多少錢一年
  • 環(huán)球網(wǎng)今日疫情消息網(wǎng)站優(yōu)化招聘
  • 網(wǎng)站建設(shè)與管理教案電商數(shù)據(jù)統(tǒng)計(jì)網(wǎng)站
  • 做網(wǎng)站的公司術(shù)語國際新聞最新消息中國
  • wordpress網(wǎng)站搭建教程視頻山東濰坊疫情最新消息
  • 長沙網(wǎng)站制作電話百度seo新算法
  • 做抖音風(fēng)的網(wǎng)站怎么優(yōu)化關(guān)鍵詞排名優(yōu)化
  • 專門做家教的網(wǎng)站營銷網(wǎng)站搭建
  • 怎么做谷歌這樣的網(wǎng)站網(wǎng)站如何做seo排名
  • 免費(fèi)推廣網(wǎng)站大全網(wǎng)如何做線上銷售和推廣
  • 如何為網(wǎng)站做優(yōu)化培訓(xùn)機(jī)構(gòu)招生方案
  • 網(wǎng)站開發(fā)創(chuàng)新點(diǎn)網(wǎng)站推廣優(yōu)化方案
  • 做logo網(wǎng)站的公司做網(wǎng)站找哪家好
  • 怎么用dw做響應(yīng)式網(wǎng)站seo教程免費(fèi)分享
  • 保定企業(yè)自助建站搜索關(guān)鍵詞優(yōu)化排名
  • 做網(wǎng)頁設(shè)計(jì)可以參考哪些網(wǎng)站長沙網(wǎng)站外包公司
  • 東莞網(wǎng)站排名優(yōu)化報價電腦培訓(xùn)學(xué)校課程
  • 相親網(wǎng)站怎么做企業(yè)線上培訓(xùn)平臺有哪些
  • 企業(yè)信息管理系統(tǒng)的發(fā)展歷程網(wǎng)站seo優(yōu)化方法
  • 網(wǎng)站建設(shè) 珠海營銷培訓(xùn)課程有哪些
  • 城關(guān)區(qū)建設(shè)局網(wǎng)站百度廣告費(fèi)一般多少錢
  • 手機(jī)網(wǎng)站開發(fā) pdf最新旅游熱點(diǎn)
  • 王妃貌美還狠兇搜索引擎優(yōu)化的作用
  • 家裝效果圖seo管理系統(tǒng)培訓(xùn)運(yùn)營
  • 網(wǎng)站制作和網(wǎng)頁制作區(qū)別上海百度推廣優(yōu)化排名