MainActivty不是从牛轧糖和奥利奥开始的



在Android 9设备(Lineage OS 16(中运行该应用程序时,它可以正常工作。但是当我尝试在牛轧糖或奥利奥等设备上打开它时,它只显示空白的白色活动。(注意:我在Android 1(Lineage OS(中只得到了这个白色的空白屏幕1或2秒,但在牛轧糖和奥利奥中,它卡在空白的白屏上(。我尝试启动其他活动,因为启动器活动和其他活动有效,但 MainActivity 类应该启动以其他活动正常工作。我不知道错误是在布局设计还是在 Java 类中(我认为错误可能不在 Java 类中,因为该应用程序在 Android 9 设备上运行良好!!!在这里,我提供了 xml 布局和 Java 类。

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/ll_ads"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" />
<RelativeLayout
android:id="@+id/track_info"
android:background="#ff0000"
android:visibility="gone"
android:layout_width="fill_parent"
android:layout_height="@dimen/track_info_layout_height"
android:layout_above="@+id/ll_ads">
<LinearLayout
android:background="@color/bottom_control_background"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.makeramen.roundedimageview.RoundedImageView
android:layout_gravity="center_vertical"
android:id="@+id/artwork_min"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4.0dip"
android:src="@drawable/default_artwork"
android:scaleType="fitXY"
android:contentDescription="@string/album_artwork" />
<RelativeLayout
android:padding="@dimen/content_padding"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:layout_weight="1.0">
<TextView
android:textSize="16.0sp"
android:textStyle="bold"
android:textColor="#ffffff"
android:ellipsize="end"
android:id="@+id/song_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:layout_alignParentTop="true" />
<TextView
android:textSize="14.0sp"
android:textColor="#ffffff"
android:ellipsize="end"
android:id="@+id/song_artist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4.0dip"
android:singleLine="true"
android:layout_below="@+id/song_title" />
</RelativeLayout>
<LinearLayout
android:id="@+id/quick_controls"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<ImageButton
android:id="@+id/quick_prev"
android:background="?selectableItemBackgroundBorderless"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/btn_prev"
android:scaleType="center"
android:contentDescription="@string/prev" />
<ImageButton
android:id="@+id/quick_play_pause_toggle"
android:background="?selectableItemBackgroundBorderless"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/btn_play"
android:scaleType="center"
android:contentDescription="@string/play" />
<ImageButton
android:id="@+id/quick_next"
android:background="?selectableItemBackgroundBorderless"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/btn_next"
android:scaleType="center"
android:contentDescription="@string/next" />
</LinearLayout>
</LinearLayout>
<com.musicplayer.players9.musicsamsung.free2018.widgets.ProgressBar
android:id="@+id/progress_bar"
android:padding="0.0dip"
android:layout_width="fill_parent"
android:layout_height="2.0dip"
android:layout_alignParentTop="true"
app:progressColor="?colorAccent" />
</RelativeLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/track_info" />
</RelativeLayout>
<android.support.design.widget.NavigationView
android:layout_gravity="start"
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
app:menu="@menu/navigation" />
</android.support.v4.widget.DrawerLayout>

Java ClassLint toJava Class

不可能...我不是在写它作为答案;一旦他阅读,我将删除它。 但是,如果逐行遵循并在执行相同的更改后,它也将得到解决

停止在mainsctivity中编码数千行

它不是所有代码、逻辑和操作的地方...!!

那么主要活动是什么,,,??

据我所知,只有 100 行代码

这 100 行代码应该做什么?

检查安卓版本,如果上面棉花糖要求下面的权限什么都不做。并在主线程上启动服务或启动另一个线程进行操作和任务..!!

溶液:

  1. 通过获取导航项目的示例代码来制作一个新项目,该代码在创建新项目时在 android 工作室中准备就绪
  2. 忘记编码。不要编写一行代码,保持原样。
  3. 检查所有模拟器,如 5.0、6.0、7.0、8.0、9.0
  4. 它会起作用,并且必须起作用..!!
  5. 现在在主活动中只需获取权限即可。
  6. 无论您需要执行什么操作,都可以在后台线程中执行。
  7. 是的,我知道你会问我想访问主用户界面...太
  8. 请参阅并执行类似此视频的示例代码...请不要避免观看它...不要欺骗自己...在安卓项目中执行操作的非常简单的演示
  9. 完成后,再次将您的代码从以前的应用程序移动到此新结构
  10. 这需要时间...,但这是正确的方法。

就是这样。

答:我知道这不是答案...,我知道这也不应该是错误

最新更新