Android 悬而未决的非开放活动

Android 悬而未决的非开放活动,android,kotlin,widget,android-pendingintent,Android,Kotlin,Widget,Android Pendingintent,我正在尝试创建一个小部件,它有一个按钮,可以打开我的应用程序,无论它是否已经打开,并且能够确认视图。setOnClickPendingEvent通过尝试打开URL来工作,但当我尝试启动设置为打开我的应用程序的PendingEvent时,它不起作用。以下是我使用的代码: val intent = Intent(context, LauncherActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent

我正在尝试创建一个小部件,它有一个按钮,可以打开我的应用程序,无论它是否已经打开,并且能够确认
视图。setOnClickPendingEvent
通过尝试打开URL来工作,但当我尝试启动设置为打开我的应用程序的
PendingEvent
时,它不起作用。以下是我使用的代码:

val intent = Intent(context, LauncherActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
val pendingIntent = PendingIntent.getActivity(context, System.currentTimeMillis().toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT)
views.setOnClickPendingIntent(R.id.title, pendingIntent)
我已经尝试过不同的旗帜,但欢迎听取任何建议

编辑:我尝试过从小部件启动其他活动,看起来效果不错,但不幸的是,打开启动程序却不行。我需要在清单中设置一些东西来打开启动器吗

以下是在清单中设置启动器的方式:

<activity
    android:name=".LauncherActivity"
    android:noHistory="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

以及一项有效的活动:

<activity android:name=".parent.ParentActivity" />


您确定这不起作用吗?可能是
活动已启动,但崩溃。检查你的日志猫(不要过滤日志猫,因为你可能会错过一条重要消息)。如果你的应用程序已经运行或没有运行,行为是否会有所不同?