2

My app has a service and an activity. From the service, on some triggers, activity is called with following code:

    Intent intent = new Intent(getApplicationContext(), MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

On my test phones (mostly Samsung, Lenovo and Huawei) , activity starts and is displayed on the phone screen with its layout. However, on Xiaomi Redmi Note 4 with Android 7, activity layout is not displayed. I only see the following line on logcat:

I/Timeline: Timeline: Activity_launch_request time:281438674 intent:Intent { flg=0x30000000 cmp=com.test.app/.MainActivity }

The activity class extends AppCompatActivity , but I also tried with a normal activity class (same layout) and the result did not change.

activity is defined like below in the manifest:

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"

        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

There is no exception or other error/warning on log. So I am not able to troubleshoot further. What can I do ?

ilker Aktuna
  • 335
  • 3
  • 8
  • what is the purpose of the 2 addFlags? – L2_Paver Nov 20 '19 at 00:44
  • their purpose is to remain only 1 instance and to be on top of other activities. But I also tried without those flags. The result was same. Activity is never seen. – ilker Aktuna Nov 20 '19 at 14:54
  • here is a best solution given by user [Redirect to your activity](https://stackoverflow.com/questions/59239077/miui-10-doesnt-let-service-start-activity-xiaomi-redmi-note) – Sagar Jun 26 '20 at 10:54

0 Answers0