Android Question How to StartActivity intent of ScreenRecorder of Android 11?

Albert Lin

Member
Licensed User
Longtime User
Dear all

Since Android 11 provides the useful ScreenRecorder, I'd like to open it programmatically?

I can start Line App by StartActivity( p.GetApplicationIntent("jp.naver.line.android") )

but when I did StartActivity(p.GetApplicationIntent("com.coloros.screenrecorder") )
it failed. the error message is "Object should first be initialized (Intent)
What possibly can I do to fix it?

Highly appreciate for any help
Albert Lin
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
it failed. the error message is "Object should first be initialized (Intent)
This means that p.GetApplicationIntent("com.coloros.screenrecorder") returned an uninitialized Intent. Maybe the package name is wrong or there is no "Main" activity defined in that app (not very likely).
 
Upvote 0

Albert Lin

Member
Licensed User
Longtime User
This means that p.GetApplicationIntent("com.coloros.screenrecorder") returned an uninitialized Intent. Maybe the package name is wrong or there is no "Main" activity defined in that app (not very likely).
Thank you, Erel.
I used a Package name app to get the packname . I also did the following code. It return the name "com.coloros.screenrecorder"
but if unmark the line If appIntent.IsInitialized Then, it'll get nothing back, so it meets the error msg "object should first be Initialized".
Now, is there possibly a thing that I can do to Start this App? Thank you a lot for your help and kindness
-------------------------------------------------------------------------------------------------------------------------
B4X:
Dim packageList As List = pm.GetInstalledPackages
    
    For i = 0 To packageList.size - 1
        Dim packageName As String = packageList.Get(i)
        Dim appIntent As Intent
        appIntent = pm.GetApplicationIntent(packageName)
        'If appIntent.IsInitialized Then
            If sAll<>"" Then sAll=sAll & CRLF
            sAll=sAll & packageName
            If packageName.ToLowerCase.Contains(theName) Then
                Return packageName
            End If
        'End If
    Next
 
Last edited:
Upvote 0

Albert Lin

Member
Licensed User
Longtime User
pm.GetApplicationIntent returns the intent that is equivalent to clicking on the app icon. It is possible that you are trying to access an app that doesn't have an app icon.
There is no this app icon on the desktop. It's hidden in the left side drawer.
I've tried to open the Drawer by hand, then execute StartActivity(p.GetApplicationIntent("com.coloros.screenrecorder") )
Still get the error message is "Object should first be initialized (Intent)

I was wondering Is there any way we can move the ScreenRecorder to desktop. if it could this problem will be solved.
 

Attachments

  • 2.JPG
    2.JPG
    51.7 KB · Views: 129
Upvote 0
Top