Checking if 'Unknown sources' is checked

DKCERT

Member
Licensed User
Longtime User
Is it possible to check if "unknown sources" has been checked (set to true) using B4A code?
 

bluejay

Active Member
Licensed User
Longtime User
No need for reflection, just use the phone library ie

Dim ph as Phone

if ph.GetSettings("install_non_market_apps") = 1 then 'can install from other sources

bluejay
 
Upvote 0

DKCERT

Member
Licensed User
Longtime User
Thanks Moster67,

I have this Sub...

B4X:
Sub GetAndroidId As String
   Dim p As Phone
   Return p.GetSettings("android_id")   
End Sub

... that I changed to this:

B4X:
Sub GetAndroidUnknownSourceStatus As String
   Dim p As Phone
   Return p.GetSettings("install_non_market_apps")   
End Sub

It seems to work :)
 
Upvote 0

DKCERT

Member
Licensed User
Longtime User
Argh BlueJay... I had the edit window open and didn't see your post. Thanks a lot - that confirms my own code triggered by Moster67 :)

No need for reflection, just use the phone library ie

Dim ph as Phone

if ph.GetSettings("install_non_market_apps") = 1 then 'can install from other sources

bluejay
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Great! I was not even aware about the GetSettings-method. Thanks.

No need for reflection, just use the phone library ie

Dim ph as Phone

if ph.GetSettings("install_non_market_apps") = 1 then 'can install from other sources

bluejay
 
Upvote 0

youjunjer

Member
Licensed User
Longtime User
This post helps me a lot
And if the value is false "cannot install from unknown sources", how to call up the option setup page for user to change this option?

Thanks Moster67,

I have this Sub...

B4X:
Sub GetAndroidId As String
   Dim p As Phone
   Return p.GetSettings("android_id")  
End Sub

... that I changed to this:

B4X:
Sub GetAndroidUnknownSourceStatus As String
   Dim p As Phone
   Return p.GetSettings("install_non_market_apps")  
End Sub

It seems to work :)
 
Upvote 0
Top