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

 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 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值