为了账号安全,请及时绑定邮箱和手机立即绑定

在共享选项列表中单击应用程序后导航到主页吗?

在共享选项列表中单击应用程序后导航到主页吗?

C#
德玛西亚99 2021-04-29 13:12:58
在共享选项列表中单击我的应用程序后,我试图导航回主页。这是我的主页:https : //gyazo.com/831db63433d9b3e2051ed605dc3489af当我在此处的共享选项列表中单击我的应用程序时:https : //gyazo.com/47234162530078e1a83cdfb17eaf5401我来到此页面:https : //gyazo.com/11cfb0f6818127e2cd4ef51d5ed970b9但是,当我在共享选项列表中单击我的应用程序时,我想导航至图片1。我怎样才能做到这一点?如图所示,共享意图活动位于AndroidManifest.xml中。图一中显示的页面称为“ TabbedPagePage”,这是我首先尝试访问的页面,而没有看到这个丑陋,没有内容的深色图片。
查看完整描述

1 回答

?
汪汪一只猫

TA贡献1898条经验 获得超8个赞

似乎您需要IntentFilter为自己设置,MainActivity而不是使用其他活动。它将最终导航到主页。

例如:


    [Activity(Label = "Navigatetomainpage", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]

    [IntentFilter(new[] { Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = "image/*", Label = "Navigatetomainpage")]

    [IntentFilter(new[] { Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = "text/plain", Label = "Navigatetomainpage")]

    [IntentFilter(new[] { Intent.ActionSendMultiple }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = "image/*", Label = "Navigatetomainpage")]    

    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity

    {

        protected override void OnCreate(Bundle bundle)

        {   

            Intent intent = Intent;

            String action = Intent.Action;

            String type = intent.Type;


            if (Intent.ActionSend.Equals(action) && type != null)

            {

                if ("text/plain".Equals(type))

                {

                    // Handle text being sent

                    // ...

                    // ...

                    // ...

                }

                else if (type.StartsWith("image/"))

                {

                    // Handle single image being sent

                    // ...

                    // ...

                    // ...    

                }

            }

            else if (Intent.ActionSendMultiple.Equals(action) && type != null)

            {

                if (type.StartsWith("image/"))

                {

                    // Handle multiple images being sent

                    // ...

                    // ...

                    // ...                        

                }

            }

            else

            {

                // Handle other intents, such as being started from the home screen                    

            }    


            TabLayoutResource = Resource.Layout.Tabbar;

            ToolbarResource = Resource.Layout.Toolbar;


            base.OnCreate(bundle);


            global::Xamarin.Forms.Forms.Init(this, bundle);

            LoadApplication(new App());

        }

    }


查看完整回答
反对 回复 2021-05-08
  • 1 回答
  • 0 关注
  • 148 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信