第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Android和Facebook共享意圖

Android和Facebook共享意圖

慕的地6264312 2019-07-09 12:51:40
Android和Facebook共享意圖我正在開(kāi)發(fā)一個(gè)Android應(yīng)用程序,我想知道如何使用Android的共享意圖從應(yīng)用程序內(nèi)部更新應(yīng)用程序用戶的狀態(tài)。在瀏覽了Facebook的SDK之后,看起來(lái)這很容易做到,但是我很想讓用戶通過(guò)常規(guī)的共享意圖彈出窗口來(lái)做這件事?見(jiàn)此:我已經(jīng)嘗試了通常的共享意圖代碼,但這似乎不再適用于Facebook。public void invokeShare(Activity activity, String quote, String credit) {     Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);     shareIntent.setType("text/plain");     shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, activity.getString(R.string.share_subject));     shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Example text");         activity.startActivity(Intent.createChooser(shareIntent, activity.getString(R.string.share_title)));}更新:在做了更多的調(diào)查之后,它看起來(lái)像是Facebook應(yīng)用程序中的一個(gè)尚未解決的bug!Facebook bug)同時(shí),看起來(lái)我不得不忍受負(fù)面的“分享不起作用!”評(píng)論。干杯Facebook:*(
查看完整描述

3 回答

?
慕容森

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超18個(gè)贊

通常的方式

創(chuàng)建所需內(nèi)容的通常方法是簡(jiǎn)單地執(zhí)行以下操作:

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, "The status update text");
    startActivity(Intent.createChooser(intent, "Dialog title text"));

這對(duì)我來(lái)說(shuō)沒(méi)有任何問(wèn)題。

另一種方法(也許)

這樣做的潛在問(wèn)題是,您還允許通過(guò)電子郵件、SMS等發(fā)送消息。下面的代碼是我在應(yīng)用程序中使用的,它允許用戶使用Gmail發(fā)送電子郵件。我猜你可以嘗試改變它,使它只適用于Facebook。

我不確定它是如何對(duì)任何錯(cuò)誤或異常做出反應(yīng)的(我猜如果沒(méi)有安裝Facebook,就會(huì)發(fā)生這種情況),所以您可能需要對(duì)其進(jìn)行一些測(cè)試。

    try {
        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        String[] recipients = new String[]{"e-mail address"};
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "E-mail subject");
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "E-mail text");
        emailIntent.setType("plain/text"); // This is incorrect MIME, but Gmail is one of the only apps that responds to it - this might need to be replaced with text/plain for Facebook
        final PackageManager pm = getPackageManager();
        final List<ResolveInfo> matches = pm.queryIntentActivities(emailIntent, 0);
        ResolveInfo best = null;
        for (final ResolveInfo info : matches)
            if (info.activityInfo.packageName.endsWith(".gm") ||
                    info.activityInfo.name.toLowerCase().contains("gmail")) best = info;
                if (best != null)
                    emailIntent.setClassName(best.activityInfo.packageName, best.activityInfo.name);
                startActivity(emailIntent);
    } catch (Exception e) {
        Toast.makeText(this, "Application not found", Toast.LENGTH_SHORT).show();
    }


查看完整回答
反對(duì) 回復(fù) 2019-07-09
  • 3 回答
  • 0 關(guān)注
  • 349 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)