0

我用谷歌搜索但没有找到 Flex 移动的帖子。我现在想要的只是在用户第一次使用该应用程序时从 TabbedViewNavigatorApplication 显示一个用户协议弹出窗口

var agreementView: UserAgreement = new UserAgreement();
PopUpManager.addPopUp(agreementView, this,true);
PopUpManager.centerPopUp(agreementView);

但也许以后更多。

请帮忙..

4

2 回答 2

1

我在我的桌面空气应用程序中做了什么;我想这也适用于移动应用程序。

确保您具有写入权限;打开 yourproject-app.mxml 向下滚动到文档末尾。在该部分中,取消注释以下权限:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

现在您可以创建文件,例如 sqlite 数据库。

在应用程序完成调用函数 checkFirstRun:

    //  functions to check if the application is run for the first time (also after updates)
    // so important structural changes can be made here.
    public var file:File;
    public var currentVersion:Number;   
    private function checkFirstRun():void
    {
    //get the current application version.
    currentVersion=getApplicationVersion();

        //get versionfile
        file = File.applicationStorageDirectory;
        file= file.resolvePath("Preferences/version.txt");
        if(file.exists)
        {
            checkVersion();
        }
        else
        {
            firstRun(); // create the version file.
        }
    }

        public function getApplicationVersion():Number
        {
            var appXML:XML = NativeApplication.nativeApplication.applicationDescriptor;
            var ns:Namespace = appXML.namespace();
            var versionnumber:Number =Number(appXML.ns::versionNumber);
            return versionnumber;       
        }
private function checkVersion():void
{
    var stream:FileStream= new FileStream();
    stream.open(file,FileMode.READ);
    var prevVersion:String = stream.readUTFBytes(stream.bytesAvailable);
    stream.close();
    if(Number(prevVersion)<currentVersion)
    {
        // if the versionnumber inside the file is older than the current version we go and run important code.
        // like alternating the structure of tables inside the sqlite database file.
        runImportantCode();

        //after running the important code, we set the version to the currentversion. 
        saveFile(currentVersion);
    }   
}
private function firstRun():void
{
    // at the first time, we set the file version to 0, so the important code will be executed. 
    var firstVersion:Number=0;
    saveFile(firstVersion);

    // we also run the checkversion so important code is run right after installing an update
    //(and the version file doesn't exist before the update).
    checkFirstRun();
}

private function saveFile(currentVersion:Number):void
{
    var stream:FileStream=new FileStream();
    stream.open(file,FileMode.WRITE);
    stream.writeUTFBytes(String(currentVersion));
    stream.close();
}


private function runImportantCode():void
{
    // here goes important code.
    // make sure you check if the important change previously has been made or not, because this code is run after each update.

}

希望这可以帮助。问候,J。

于 2012-07-24T09:26:01.950 回答
0

Some you need to store whether the user has agreed to the agreement or not. IF they haven't agreed, then show it.

One way to do this would be to store a value in a shared object. Another way to do this would be to use a remote service and store such data in a central repository. I assume you'll want the second; so you can do some form of tracking against the number of users using your app.

于 2012-04-28T14:03:17.157 回答