当前位置: 首页>>代码示例>>Java>>正文


Java ShareCompat.IntentReader方法代码示例

本文整理汇总了Java中android.support.v4.app.ShareCompat.IntentReader方法的典型用法代码示例。如果您正苦于以下问题:Java ShareCompat.IntentReader方法的具体用法?Java ShareCompat.IntentReader怎么用?Java ShareCompat.IntentReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.app.ShareCompat的用法示例。


在下文中一共展示了ShareCompat.IntentReader方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCallingApplication

import android.support.v4.app.ShareCompat; //导入方法依赖的package包/类
@Nullable
private String getCallingApplication(ShareCompat.IntentReader intentReader) {
    String callingPackage = intentReader.getCallingPackage();
    if (TextUtils.isEmpty(callingPackage)) {
        Uri referrer = ActivityCompat.getReferrer(this);
        if (referrer != null) {
            callingPackage = referrer.getHost();
        }
    }
    CharSequence label = null;
    if (!TextUtils.isEmpty(callingPackage)) {
        PackageManager pm = getPackageManager();
        try {
            label = pm.getApplicationLabel(pm.getApplicationInfo(callingPackage, 0));
        } catch (PackageManager.NameNotFoundException e) {
            Log.w(TAG, "Could not retrieve label for package " + callingPackage, e);
        }
    }
    return label != null ? label.toString() : null;
}
 
开发者ID:romannurik,项目名称:muzei,代码行数:21,代码来源:GalleryAddPhotosActivity.java

示例2: handleShareIntent

import android.support.v4.app.ShareCompat; //导入方法依赖的package包/类
private void handleShareIntent(final ShareCompat.IntentReader reader) {
    Analytics.event(Analytics.SHARE_VIA_ROBIRD);
    if (reader.getStreamCount() > 0) {
        final int count = reader.getStreamCount() > 4 ? 4 : reader.getStreamCount();
        ComposeFragment
                .share(new ArrayList<Uri>() {
                    {
                        for (int i = 0; i < count; ++i)
                            add(reader.getStream(i));
                    }
                })
                .show(getSupportFragmentManager(), ComposeFragment.TAG_SHARE);
    } else {
        final StringBuilder shareBuilder = new StringBuilder();

        if (!TextUtils.isEmpty(reader.getSubject()))
            shareBuilder.append(reader.getSubject()).append(" ");

        shareBuilder.append(reader.getText());

        ComposeFragment
                .share(shareBuilder.toString())
                .show(getSupportFragmentManager(), ComposeFragment.TAG_SHARE);
    }
}
 
开发者ID:mecid,项目名称:robird-reborn,代码行数:26,代码来源:HomeActivity.java

示例3: onCreate

import android.support.v4.app.ShareCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    analytics.sendScreenView("AddToHomeScreen");

    final ShareCompat.IntentReader reader = ShareCompat.IntentReader.from(this);
    String foundUrl = Urls.extractUrlFrom(getIntent(), reader);

    if (foundUrl != null) {
        Intent intent = RedirectFixActivity.createIntent(this, foundUrl)
                .putExtra(ResolverActivity.EXTRA_ADD_TO_HOME_SCREEN, true);
        startActivity(intent);
    } else {
        Toast.makeText(this, R.string.error_invalid_url, Toast.LENGTH_SHORT).show();
    }

    finish();
}
 
开发者ID:tasomaniac,项目名称:OpenLinkWith,代码行数:19,代码来源:AddToHomeScreen.java

示例4: extractTitle

import android.support.v4.app.ShareCompat; //导入方法依赖的package包/类
/**
 * Method to extract the title from shared data
 **/
private String extractTitle(ShareCompat.IntentReader reader) {
    if (reader.getSubject() != null && !NetworkManager.isUrl(reader.getSubject())){
        return reader.getSubject();
    }

    return "";
}
 
开发者ID:dimtion,项目名称:Shaarlier,代码行数:11,代码来源:AddActivity.java

示例5: onCreate

import android.support.v4.app.ShareCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);

    analytics.sendScreenView("ShareToOpenWith");
    if (isFromDirectShare(getIntent())) {
        analytics.sendEvent(
                "Direct Share",
                "Clicked",
                "true"
        );
    }

    final ShareCompat.IntentReader reader = ShareCompat.IntentReader.from(this);
    String foundUrl = Urls.extractUrlFrom(getIntent(), reader);

    if (foundUrl != null) {
        String callerPackage = CallerPackageExtractor.from(this).extract();
        Intent intent = RedirectFixActivity.createIntent(this, foundUrl)
                .putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, callerPackage);
        startActivity(intent);
    } else {
        Toast.makeText(this, R.string.error_invalid_url, Toast.LENGTH_SHORT).show();
    }
    finish();
}
 
开发者ID:tasomaniac,项目名称:OpenLinkWith,代码行数:28,代码来源:ShareToOpenWith.java

示例6: extractUrlFrom

import android.support.v4.app.ShareCompat; //导入方法依赖的package包/类
@Nullable
public static String extractUrlFrom(Intent intent, ShareCompat.IntentReader reader) {
    CharSequence text = reader.getText();
    if (text == null) {
        text = getExtraSelectedText(intent);
    }
    return findFirstUrl(text);
}
 
开发者ID:tasomaniac,项目名称:OpenLinkWith,代码行数:9,代码来源:Urls.java

示例7: onCreate

import android.support.v4.app.ShareCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ShareCompat.IntentReader intentReader =
            ShareCompat.IntentReader.from(this);
    if (!intentReader.isShareIntent()) {
        finish();
        return;
    }
    String callingApplication = getCallingApplication(intentReader);
    mStreamCount = intentReader.getStreamCount();
    for (int index = 0; index < mStreamCount; index++) {
        final Uri photoUri = intentReader.getStream(index);
        ChosenPhoto chosenPhoto = new ChosenPhoto(photoUri);

        final LiveData<Long> insertLiveData = GalleryDatabase.getInstance(this).chosenPhotoDao()
                .insert(this, chosenPhoto, callingApplication);
        insertLiveData.observeForever(new Observer<Long>() {
            @Override
            public void onChanged(@Nullable final Long id) {
                insertLiveData.removeObserver(this);
                if (id == null || id == 0L) {
                    Log.e(TAG, "Unable to insert chosen artwork for " + photoUri);
                    mFailureCount++;
                } else {
                    mSuccessCount++;
                }
                updateCount();
            }
        });
    }
}
 
开发者ID:romannurik,项目名称:muzei,代码行数:33,代码来源:GalleryAddPhotosActivity.java

示例8: onCreate

import android.support.v4.app.ShareCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post_new_designer_news_story);
    ButterKnife.bind(this);
    if (!FabTransform.setup(this, bottomSheetContent)) {
        MorphTransform.setup(this, bottomSheetContent,
                ContextCompat.getColor(this, R.color.background_light), 0);
    }

    bottomSheet.registerCallback(new BottomSheet.Callbacks() {
        @Override
        public void onSheetDismissed() {
            // After a drag dismiss, finish without the shared element return transition as
            // it no longer makes sense.  Let the launching window know it's a drag dismiss so
            // that it can restore any UI used as an entering shared element
            setResult(RESULT_DRAG_DISMISSED);
            finish();
        }
    });

    scrollContainer.setListener(new ObservableScrollView.OnScrollListener() {
        @Override
        public void onScrolled(int scrollY) {
            if (scrollY != 0
                    && sheetTitle.getTranslationZ() != appBarElevation) {
                sheetTitle.animate()
                        .translationZ(appBarElevation)
                        .setStartDelay(0L)
                        .setDuration(80L)
                        .setInterpolator(AnimUtils.getFastOutSlowInInterpolator
                                (PostNewDesignerNewsStory.this))
                        .start();
            } else if (scrollY == 0 && sheetTitle.getTranslationZ() == appBarElevation) {
                sheetTitle.animate()
                        .translationZ(0f)
                        .setStartDelay(0L)
                        .setDuration(80L)
                        .setInterpolator(AnimUtils.getFastOutSlowInInterpolator
                                (PostNewDesignerNewsStory.this))
                        .start();
            }
        }
    });

    // check for share intent
    if (isShareIntent()) {
        ShareCompat.IntentReader intentReader = ShareCompat.IntentReader.from(this);
        url.setText(intentReader.getText());
        title.setText(intentReader.getSubject());

        // when receiving a share there is no shared element transition so animate up the
        // bottom sheet to establish the spatial model i.e. that it can be dismissed downward
        overridePendingTransition(R.anim.post_story_enter, R.anim.fade_out_rapidly);
        bottomSheetContent.getViewTreeObserver().addOnPreDrawListener(
                new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                bottomSheetContent.getViewTreeObserver().removeOnPreDrawListener(this);
                bottomSheetContent.setTranslationY(bottomSheetContent.getHeight());
                bottomSheetContent.animate()
                        .translationY(0f)
                        .setStartDelay(120L)
                        .setDuration(240L)
                        .setInterpolator(AnimUtils.getLinearOutSlowInInterpolator
                                (PostNewDesignerNewsStory.this));
                return false;
            }
        });
    }
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:72,代码来源:PostNewDesignerNewsStory.java

示例9: onCreate

import android.support.v4.app.ShareCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post_new_designer_news_story);
    ButterKnife.bind(this);
    if (!FabTransform.setup(this, bottomSheetContent)) {
        MorphTransform.setup(this, bottomSheetContent,
                ContextCompat.getColor(this, R.color.background_light), 0);
    }

    bottomSheet.registerCallback(new BottomSheet.Callbacks() {
        @Override
        public void onSheetDismissed() {
            // After a drag dismiss, finish without the shared element return transition as
            // it no longer makes sense.  Let the launching window know it's a drag dismiss so
            // that it can restore any UI used as an entering shared element
            setResult(RESULT_DRAG_DISMISSED);
            finish();
        }
    });

    scrollContainer.setListener(new ObservableScrollView.OnScrollListener() {
        @Override
        public void onScrolled(int scrollY) {
            if (scrollY != 0
                    && sheetTitle.getTranslationZ() != appBarElevation) {
                sheetTitle.animate()
                        .translationZ(appBarElevation)
                        .setStartDelay(0L)
                        .setDuration(80L)
                        .setInterpolator(AnimUtils.getFastOutSlowInInterpolator
                                (PostNewDesignerNewsStory.this))
                        .start();
            } else if (scrollY == 0 && sheetTitle.getTranslationZ() == appBarElevation) {
                sheetTitle.animate()
                        .translationZ(0f)
                        .setStartDelay(0L)
                        .setDuration(80L)
                        .setInterpolator(AnimUtils.getFastOutSlowInInterpolator
                                (PostNewDesignerNewsStory.this))
                        .start();
            }
        }
    });

    // check for share intent
    if (isShareIntent()) {
        ShareCompat.IntentReader intentReader = ShareCompat.IntentReader.from(this);
        url.setText(intentReader.getText());
        title.setText(intentReader.getSubject());
    }
    if (!hasSharedElementTransition()) {
        // when launched from share or app shortcut there is no shared element transition so
        // animate up the bottom sheet to establish the spatial model i.e. that it can be
        // dismissed downward
        overridePendingTransition(R.anim.post_story_enter, R.anim.post_story_exit);
        bottomSheetContent.getViewTreeObserver().addOnPreDrawListener(
                new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                bottomSheetContent.getViewTreeObserver().removeOnPreDrawListener(this);
                bottomSheetContent.setTranslationY(bottomSheetContent.getHeight());
                bottomSheetContent.animate()
                        .translationY(0f)
                        .setStartDelay(120L)
                        .setDuration(240L)
                        .setInterpolator(AnimUtils.getLinearOutSlowInInterpolator
                                (PostNewDesignerNewsStory.this));
                return false;
            }
        });
    }
    ShortcutHelper.reportPostUsed(this);
}
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:75,代码来源:PostNewDesignerNewsStory.java

示例10: onCreate

import android.support.v4.app.ShareCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post_new_designer_news_story);
    ButterKnife.bind(this);
    if (!FabTransform.setup(this, bottomSheetContent)) {
        MorphTransform.setup(this, bottomSheetContent,
                ContextCompat.getColor(this, R.color.background_light), 0);
    }

    bottomSheet.registerCallback(new BottomSheet.Callbacks() {
        @Override
        public void onSheetDismissed() {
            // After a drag dismiss, finish without the shared element return transition as
            // it no longer makes sense.  Let the launching window know it's a drag dismiss so
            // that it can restore any UI used as an entering shared element
            setResult(RESULT_DRAG_DISMISSED);
            finish();
        }
    });

    scrollContainer.setListener(scrollY -> {
        if (scrollY != 0
                && sheetTitle.getTranslationZ() != appBarElevation) {
            sheetTitle.animate()
                    .translationZ(appBarElevation)
                    .setStartDelay(0L)
                    .setDuration(80L)
                    .setInterpolator(AnimUtils.getFastOutSlowInInterpolator
                            (PostNewDesignerNewsStory.this))
                    .start();
        } else if (scrollY == 0 && sheetTitle.getTranslationZ() == appBarElevation) {
            sheetTitle.animate()
                    .translationZ(0f)
                    .setStartDelay(0L)
                    .setDuration(80L)
                    .setInterpolator(AnimUtils.getFastOutSlowInInterpolator
                            (PostNewDesignerNewsStory.this))
                    .start();
        }
    });

    // check for share intent
    if (isShareIntent()) {
        ShareCompat.IntentReader intentReader = ShareCompat.IntentReader.from(this);
        url.setText(intentReader.getText());
        title.setText(intentReader.getSubject());
    }
    if (!hasSharedElementTransition()) {
        // when launched from share or app shortcut there is no shared element transition so
        // animate up the bottom sheet to establish the spatial model i.e. that it can be
        // dismissed downward
        overridePendingTransition(R.anim.post_story_enter, R.anim.post_story_exit);
        bottomSheetContent.getViewTreeObserver().addOnPreDrawListener(
                new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                bottomSheetContent.getViewTreeObserver().removeOnPreDrawListener(this);
                bottomSheetContent.setTranslationY(bottomSheetContent.getHeight());
                bottomSheetContent.animate()
                        .translationY(0f)
                        .setStartDelay(120L)
                        .setDuration(240L)
                        .setInterpolator(AnimUtils.getLinearOutSlowInInterpolator
                                (PostNewDesignerNewsStory.this));
                return false;
            }
        });
    }
    ShortcutHelper.reportPostUsed(this);
}
 
开发者ID:nickbutcher,项目名称:plaid,代码行数:72,代码来源:PostNewDesignerNewsStory.java

示例11: onCreate

import android.support.v4.app.ShareCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // setContentView(R.layout.activity_add);
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    // Get the user preferences :
    SharedPreferences pref = getSharedPreferences(getString(R.string.params), MODE_PRIVATE);
    this.privateShare = pref.getBoolean(getString(R.string.p_default_private), true);
    this.m_prefOpenDialog = pref.getBoolean(getString(R.string.p_show_share_dialog), true);
    this.autoTitle = pref.getBoolean(getString(R.string.p_auto_title), true);
    this.autoDescription = pref.getBoolean(getString(R.string.p_auto_description), false);
    this.tweet = pref.getBoolean(getString(R.string.p_shaarli2twitter), false);
    stopLoadingTitle = false;
    stopLoadingDescription = false;

    // Check if there is at least one account, if so launch the settings :
    getAllAccounts();
    if (this.allAccounts.isEmpty()) {
        Intent intentLaunchSettings = new Intent(this, MainActivity.class);
        startActivity(intentLaunchSettings);
    } else if (Intent.ACTION_SEND.equals(action) && "text/plain".equals(type)) {
        ShareCompat.IntentReader reader = ShareCompat.IntentReader.from(this);
        String sharedUrl = reader.getText().toString();

        String sharedUrlTrimmed = this.extractUrl(sharedUrl);
        String defaultTitle = this.extractTitle(reader);

        String defaultDescription = intent.getStringExtra("description") != null ? intent.getStringExtra("description") : "";
        String defaultTags = intent.getStringExtra("tags") != null ? intent.getStringExtra("tags") : "";

        if (!autoTitle){
            defaultTitle = "";
        }
        if (!autoDescription){
            defaultDescription = "";
        }

        // Show edit dialog if the users wants
        if (m_prefOpenDialog) {
            handleDialog(sharedUrlTrimmed, defaultTitle, defaultDescription, defaultTags);
        } else {
            if (autoTitle || autoDescription) {
                loadAutoTitleAndDescription(sharedUrlTrimmed, defaultTitle, defaultDescription);
            }
            handleSendPost(sharedUrlTrimmed, defaultTitle, defaultDescription, defaultTags, privateShare, this.chosenAccount, this.tweet);
        }
    } else {
        Toast.makeText(getApplicationContext(), R.string.add_not_handle, Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:dimtion,项目名称:Shaarlier,代码行数:54,代码来源:AddActivity.java


注:本文中的android.support.v4.app.ShareCompat.IntentReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。