Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

My Android App Needs To Check If Another One Of My Apps Is Installed On The Device ( On Ios I Use Url Schemes )
Started by a.lepel Apr 10 2013 06:42 AM

8 replies to this topic
url scheme

Best Answer Joshua Quick , 12 April 2013 - 03:59 PM

Andreas,

 

I have an alternative solution for you.  As of daily build #1081 (coming soon), we've added the ability to display app icons belonging to the currently running Android application or other Android applications by their package name.  It was intended for 3rd party Lua libraries, but this can definitely be used to detect if your app is installed on the device... at the expense of loading an image and wasting memory, but that said, app icons are not that big.

 

local appIcon = display.newImage("android.app.icon://my.package.name")
if appIcon then
   -- App is installed.
else
   -- App is not installed.
end

 

 

For example, try it with package name "com.android.vending" which will fetch the Google Play app icon.

Also note that you can load app icons with this URL scheme via display.newImageRect() as well.

 

Anyways, I hope this helps!

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

a.lepel

[GLOBAL: userInfoPane.html]
a.lepel
  • Contributor

  • 104 posts
  • Corona SDK

Hello,
 
my game should know if another of my games is installed on the same device.
 
On iOS I tell the user in game #1 that for some bonus content he needs to start game #2 using a button.
Now I open game #2 using an URL scheme, when system.openURL() returns "true" (since build #968) I unlock the bonus content in game #1, otherwise I send the user directly to the App Store to download game #2. :-)
 
But I don't have the slightest idea how to implement this for Android...
[ And I would like not to do stuff like generating special IDs in one app that the user has to input in the other app, or setting flags in a remote server, or other awkward workarounds ]
 
Any ideas?
 
Thanks & best,
Andreas

 

 



[TOPIC: post.html]
#2

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

There is currently no way to do this via Corona's Lua APIs, but this can be done in Java via Corona Enterprise.  On Android, you would normally do this by finding the app by its package name by calling the PackageManager.getPackageInfo() Java method, as documented here...

http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackageInfo(java.lang.String,%20int)



[TOPIC: post.html]
#3

a.lepel

[GLOBAL: userInfoPane.html]
a.lepel
  • Contributor

  • 104 posts
  • Corona SDK

Hi Joshua,

thank you very much for the fast answer. Now I know I can continue with this - and when in about 6 month the project will be almost finished I will have to look again if this is already implemented for Android or I will have to switch to Enterprise.

Best,

Andreas



[TOPIC: post.html]
#4

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

  Best Answer

Andreas,

 

I have an alternative solution for you.  As of daily build #1081 (coming soon), we've added the ability to display app icons belonging to the currently running Android application or other Android applications by their package name.  It was intended for 3rd party Lua libraries, but this can definitely be used to detect if your app is installed on the device... at the expense of loading an image and wasting memory, but that said, app icons are not that big.

 

local appIcon = display.newImage("android.app.icon://my.package.name")
if appIcon then
   -- App is installed.
else
   -- App is not installed.
end

 

 

For example, try it with package name "com.android.vending" which will fetch the Google Play app icon.

Also note that you can load app icons with this URL scheme via display.newImageRect() as well.

 

Anyways, I hope this helps!



[TOPIC: post.html]
#5

a.lepel

[GLOBAL: userInfoPane.html]
a.lepel
  • Contributor

  • 104 posts
  • Corona SDK

Hi Joshua,

that's it, exactly what I need. Thanks!

Best,

Andreas



[TOPIC: post.html]
#6

pranav.khandelwal

[GLOBAL: userInfoPane.html]
pranav.khandelwal
  • Enthusiast

  • 30 posts
  • Corona SDK

I want to open 3rd party application in my application..?

I Know how to handle when any application open yours application but i didn't know how to open application



[TOPIC: post.html]
#7

Beloudest

[GLOBAL: userInfoPane.html]
Beloudest
  • Contributor

  • 189 posts
  • Corona SDK

This returns a error if the app is not present thus breaking my loop. How can I safely check it exists or continue when it returns nil. Thanks?



[TOPIC: post.html]
#8

Trung Kien Tran

[GLOBAL: userInfoPane.html]
Trung Kien Tran
  • Enthusiast

  • 61 posts
  • Corona SDK

Andreas,

 

I have an alternative solution for you.  As of daily build #1081 (coming soon), we've added the ability to display app icons belonging to the currently running Android application or other Android applications by their package name.  It was intended for 3rd party Lua libraries, but this can definitely be used to detect if your app is installed on the device... at the expense of loading an image and wasting memory, but that said, app icons are not that big.

local appIcon = display.newImage("android.app.icon://my.package.name")
if appIcon then
   -- App is installed.
else
   -- App is not installed.
end

For example, try it with package name "com.android.vending" which will fetch the Google Play app icon.

Also note that you can load app icons with this URL scheme via display.newImageRect() as well.

 

Anyways, I hope this helps!

How to using for Windows Phone?



[TOPIC: post.html]
#9

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Moderator

  • 3,397 posts
  • Corona Staff

>> How to using for Windows Phone?

 

We don't have a solution on WP8.  You'll have to do this yourself via .NET (ie: C# or Visual Basic).

No one over here has done this before on WP8.  So, you'll have to Google search this one for yourself.




[topic_controls]
[/topic_controls]