Skip to main content

How to support Amazon and Android Market links in same APK



Possible Duplicate:

Supporting Amazon and Android market links inside application




I was wondering if and how you could differentiate between an Amazon App Store installed app and one installed from the Market.



For example, say I have my app called "Example App", and I want to develop for Amazon and the Market. In the app I have links to rate Example App. I also have a link to buy Example App Pro. This poses a problem because Amazon will not release my app if it links to a different App store.



This requires me to make 2 APK files, which is a pain. It only takes about 30 seconds extra to export both, but it creates extra clutter and testing time.



So has anyone found a way to make a single APK that can be uploaded to both Amazon and Android Market without making any changes between the two so that at run time I can check whether it's the Amazon or the Market that installed it and change the links accordingly?


Source: Tips4allCCNA FINAL EXAM

Comments

  1. You will have to sign the application as normal, run on your test device, get the value of sig.hashCode() from your logs, then replace -1545485543 with whatever value you got for sig.hashCode() then export and sign again (WITH THE SAME KEY AS BEFORE) and then upload to Amazon and Market both - from the same APK.

    Do it:

    public static boolean isMarket(Context context){
    boolean isMarketSig = false;
    int currentSig = 1; // I just set this to 1 to avoid any exceptions later on.
    try {
    Signature[] sigs = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES).signatures;
    for (Signature sig : sigs)
    {
    currentSig = sig.hashCode();


    Log.i("MyApp", "Signature hashcode : " + sig.hashCode());
    // This Log is for first time testing so you can find out what the int value of your signature is.
    }
    } catch (Exception e){
    e.printStackTrace();


    }
    //-1545485543 was the int I got from the log line above, so I compare the current signature hashCode value with that value to determine if it's market or not.
    if (currentSig==-1545485543){
    isMarketSig = true;
    } else {
    isMarketSig = false;
    }

    return isMarketSig;
    }
    public static void openStore(Context context){
    if (isMarket(context)){
    Intent goToMarket = new Intent(Intent.ACTION_VIEW,Uri.parse("market://d" +
    "etails?id=com.jakar.myapp"));
    goToMarket.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(goToMarket);
    } else {
    Intent goToAppstore = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.amazon.com/gp/mas/dl/andro" +
    "id?p=com.jakar.myapp"));
    goToAppstore.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(goToAppstore);
    }
    }


    Basically, the hashCode() that you get from the app installed on your testing device will be the same one from the market. The hash code from the app store will be different because according to https://developer.amazon.com/help/faq.html, the app store signs the application with a signature specific to your developer account, so that will return a different value that what you actually signed it with.

    And I put the isMarket and openStore methods in a different class called OtherClass so that I only have to code it once. Then from any activity where I need to open the proper link, I just call OtherClass.openStore(context);

    Note: It works to open the market successfully, but I haven't yet deployed this method on the App Store, so I haven't completely tested it. I am confident it will work, but can make no guarantees, so if you use what I've suggested and it fails, please don't hold me accountable.

    This was a big help in coming up with an answer so I could test which signature was being used.

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex