English 中文(简体)
通过Facebook、Twitter、Email和Mesaging来分享申请
原标题:Share Application Through Facebook, Twitter, Email, and Messaging Only
  • 时间:2011-08-17 07:13:34
  •  标签:
  • android

我想通过Facebook、Twitter、电子邮件和讯息分享我的申请。 我不想与使用份额纽扣时提出的其他选择分享。

目前,我正在使用以下表格:

sharebuton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        String TEXT = "I shared the file " + " via MyApp";
        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setType("text/plain");
        sendIntent.putExtra(Intent.EXTRA_TEXT, TEXT);
        startActivity(Intent.createChooser(sendIntent, "Share the program:"));
    }
});

在使用该守则时,向用户介绍其他选择,如Gmail, Notepad, Peep, Bluetooth等,以及上述四种选择。

是否有可能过滤共享选择,以便只有四种选择(Facebook、Twitter、电子邮件和电传)提交用户?

问题回答

我不敢肯定你是否仍然找回答案,但最近我就完全是你试图做些什么,而恰恰相反,想建立一个用户可以分享的定制清单,将Facebook排除在外。 你们需要知道你希望排除/列入的一揽子名单。 我在此守则中基本上列出了为处理行动而登记的一揽子计划清单。 风险简介,然后,你可以选择你想要显示的名单上哪些项目。

    List<Intent> targetedShareIntents = new ArrayList<Intent>();
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/jpeg");
    List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(intent, 0);
    if (!resInfo.isEmpty()) {
        for (ResolveInfo resolveInfo : resInfo) {
            String packageName = resolveInfo.activityInfo.packageName;
            Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND);
            targetedShareIntent.setType("image/jpeg");
            targetedShareIntent.putExtra(Intent.EXTRA_TITLE, "Title string");
            targetedShareIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject string");
            if ("com.facebook.katana".equals(packageName) || "com.facebook.orca".equals(packageName)) {
                    // don t add Facebook or Facebook messenger app to list
                continue;
            } else {
                targetedShareIntent.putExtra(Intent.EXTRA_TEXT, bodyStr);
            }
            targetedShareIntent.setPackage(packageName);
            targetedShareIntents.add(targetedShareIntent);
        }
        Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), getString(R.string.results_share_title));
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{}));
        startActivity(chooserIntent);
    }

引证。

如果你想通过Facebook、前线、电子邮件和讯息分享申请。

为此,你需要制定<代码>layout,在其中,你必须提出希望分享的选择方案。 您可为此制定<代码>buttons。

然后点击button 届时,您需要处理诸如<代码>email等每一纽扣吨的行动。 页: 1 页: 1 与其他人一样。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签