Android Question Unreachable Code detected.

Theera

Well-Known Member
Licensed User
Longtime User
I have studied Shortcut creating ,and have followed the example code. It has error code "Unreachable Code detected."
I have adding some code in manifest file.
'<uses-AddPermission android:name="CreateResourceFromFile.android.launcher.Permission.CREATE_SHORTCUT"/>

AddPermission(android.permission.CREATE_SHORTCUT)
I don't know how to solve my problem.
 

Attachments

  • createshortcut.zip
    55.1 KB · Views: 103
Solution
You placed a code after a RETURN. It means that code will not be executed.

B4X:
Private Sub    CreateIconFromBitmap() As Object
            
     Dim ic As JavaObject
     Return '<<<<<<<---------------------------THIS IS THE PROBELM
     'ic.InitializeStatic("androidx.core.graphics.drawable.IconCompat").RunMethod("createWithBitmap",Array(LoadBitmap(File.DirAssets,"android-icon-72x72.png")))
    ic.InitializeStatic("androidx.core.graphics.drawable.IconCompat").RunMethod("createWithBitmap",Array(LoadBitmap(File.DirAssets,"Letter-S-icon.png")))
    
    
End Sub

mcqueccu

Well-Known Member
Licensed User
Longtime User
You placed a code after a RETURN. It means that code will not be executed.

B4X:
Private Sub    CreateIconFromBitmap() As Object
            
     Dim ic As JavaObject
     Return '<<<<<<<---------------------------THIS IS THE PROBELM
     'ic.InitializeStatic("androidx.core.graphics.drawable.IconCompat").RunMethod("createWithBitmap",Array(LoadBitmap(File.DirAssets,"android-icon-72x72.png")))
    ic.InitializeStatic("androidx.core.graphics.drawable.IconCompat").RunMethod("createWithBitmap",Array(LoadBitmap(File.DirAssets,"Letter-S-icon.png")))
    
    
End Sub
 
Upvote 0
Solution
Top