restrict the windows phone app for specific devices

江枫思渺然 提交于 2019-12-25 05:17:15

问题


i want my application should work on specific devices\OS like "Lumia 650"\"windows phone 8", this is my project requirement.

Is it possible ? if yes where should I mention the details ?


回答1:


It is not a problem to restrict Windows Phone 8. You just need to build it targeting Windows Phone OS 8.0. For the device model you do something like this in the App.xaml.cs

    private void Application_Launching(object sender, LaunchingEventArgs e)
    {
        var deviceName = DeviceExtendedProperties.GetValue("DeviceName").ToString();
        if (!deviceName.Contains("Lumia_650")) // Please check your phone's actual value
            Application.Current.Terminate();
    }

If you want to show a friendly message before it exits you can move the code to the MainPage.xaml.cs then add the MessageBox.Show(message) part.




回答2:


This is only possible in code as you can not prevent users from installing the app if the app is meant for that particular OS what that user has. However, once the app is launched you can get the name of the device and do actions accordingly.

You can try this:

var PhoneName = Microsoft.Phone.Info.DeviceStatus.DeviceName;

if(PhoneName == "Not Allowed Phone")
{
     MessageBox.Show("You can not use this app");
}
else
{

}


来源:https://stackoverflow.com/questions/22610479/restrict-the-windows-phone-app-for-specific-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!