专业版和免费版程序处理策略

 I'd like to know how your customers feel about having a limited-time 
> trial-demo that can be unlocked by downloading a 'license key'-app. Is 
> this better than having two versions of your app around? 
Without running an A-B test I'm not sure how I'd evaluate which one's 
better. Generally I've not had many problems from the customer side, 
but I provide quite a bit of guidance: in various dialogs that appear, 
in the Market description for the license, on my app's website, and 
even in a small HTML "license help" page I bundle with the APK and 
open in a WebView if the user's having trouble. For me, I think it's 
still easier than trying to keep the source code of free+paid versions 
synchronized, but YMMV. 

In answer to some of the other questions floating around on this 
thread... 

My code (in the "trial") to check for the license looks like this: 

final PackageManager pkgMgr = context.getPackageManager(); 
final int sigMatch = 
pkgMgr.checkSignatures(appContext.getPackageName(), 
"com.package.of.license"); 
if (sigMatch == PackageManager.SIGNATURE_MATCH) { 
        // License found 
        ... 

 


Note that both apps (trial/license) need to be signed with the same 
key for this to work. That's a pretty central part of this approach. 

And in my license, rather than removing the MAIN & LAUNCHER intents 
from the manifest, I have code like this in the activity's onCreate: 

final PackageManager pkgMgr = getPackageManager(); 
final int sigMatch = pkgMgr.checkSignatures(this.getPackageName(), 
MAIN_APP_PACKAGE_NAME); 
if (sigMatch == PackageManager.SIGNATURE_MATCH) { 
        Intent intent = new Intent(Intent.ACTION_MAIN); 
        intent.setComponent(new ComponentName(MAIN_APP_PACKAGE_NAME, 
MAIN_APP_PACKAGE_NAME + ".MainActivity")); 
        startActivity(intent); 

        // Remove this app from the Launcher 
        pkgMgr.setComponentEnabledSetting( 
                        new ComponentName(PACKAGE_NAME, PACKAGE_NAME + ".LicenseActivity"), 
                        PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 
                        PackageManager.DONT_KILL_APP); 

} else { 
        // Main app not installed 
        AlertDialog.Builder builder = new AlertDialog.Builder(this); 
        builder.setMessage(R.string.download_instr) 
        .setPositiveButton(R.string.download, new 
DialogInterface.OnClickListener() { 
                public void onClick(DialogInterface dialog, int id) { 
                        Intent marketLaunch = new Intent(Intent.ACTION_VIEW); 
                        marketLaunch.setData(Uri.parse("market://details?id=" + 
MAIN_APP_PACKAGE_NAME)); 
                        try { 
                                startActivity(marketLaunch); 
                        } catch (Exception e) { 
                                Toast.makeText(LicenseActivity.this, R.string.no_market, 
Toast.LENGTH_LONG).show(); 
                        } 
                        LicenseActivity.this.finish(); 
                } 
        }) 
        .setNegativeButton(R.string.cancel, new 
DialogInterface.OnClickListener() { 
                public void onClick(DialogInterface dialog, int id) { 
                        LicenseActivity.this.finish(); 
                } 
        }) 
        .create().show(); 

 


This code uses a couple of static strings for the two package names 
involved. It covers the following eventualities: 
- If the user has the main ("trial") app already installed, this 
starts its MainActivity, then removes itself from the Launcher 
- If they don't, it shows them a dialog with a link to a market search 
for it 
阅读更多
个人分类: android 后台功能
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭