开发者

Android Application Registy

My requirement is, First time appl开发者_JAVA技巧ication is installed in the Android phone, Need to get the licence code from particular shop/organization. I have created generation key using phone model number.nOW THE PROBLEM IS If its first only need to show license screen otherwise go to first screen. How we can identify the particular app is installed already or not . / from the registry ? In here registry is available.

I couldn't explore my very deeply or clearly. Sorry for that.

Please help me.

Thanks in advance...


You could always set a bool value in the android.content.SharedPreferences, then in the first oncreate() check to see whether that bool value is false.

If it is push the license screen intent and perform a check for application, if its there update the preference to true. So on next start it will skip over it, where you can load your main screen.

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

settings = getSharedPreferences(PREFS_NAME, 0);
boolean enteredDetails = settings.getBoolean("FirstTime", false);



if(enteredDetails){
setContentView(R.layout.main); //loads the main screen            
}
else{
startActivityForResult(new Intent(this, License.class), GET_DETAILS); 
}
}


You can simply use Context.openFileInput() / Context.openFileOutput() to store a piece of information that will tell your app whether the license screen was already shown. This way you can use something like this in your main Activity's onCreate():

if (nothingWrittenInAFileCalled(FILE_NAME)) { // using Context.openFileInput()
     showLicense();
     writeAFileCalled(FILE_NAME); // using Context.openFileOutput()
}

If this is not satisfactory, this is also something you can check on license server side. If you send the license server a hash of the IMEI, as an example, your license server will be able to determine whether the app was already installed or not. In that case, prefer a non reversible hash: this is to avoid sending/storing the IMEI as one can see this piece of information as private data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜