简体   繁体   English

以编程方式打开Blackberry设备选项

[英]Open blackberry device options programmatically

App details: 应用详细信息:

I am writing an app that requires the user to have a device password set. 我正在编写一个要求用户设置设备密码的应用程序。 The company distributes blackberry devices to its associates who will then use them to report on sales etc. The company wants to make sure that the device password is set so that the confidential information can not be easily accessed by anyone if they steal the phone. 该公司向其员工分发黑莓设备,然后他们将使用它们来报告销售情况等。该公司希望确保设置了设备密码,这样,如果任何人窃取了电话,机密信息就不会轻易被访问。 The app must not work if the password is not set, which is easy enough. 如果未设置密码,该应用程序将无法运行,这很容易。

The problem: 问题:

The company wants the a message to come up saying "Please set a device password" and then direct the user to the device to the options menu to show them where to set their device password. 该公司希望出现一条消息,提示“请设置设备密码”,然后将用户定向到设备的选项菜单,以向他们显示在何处设置其设备密码。 Doing this seems troublesome 这样做似乎很麻烦

What I have tried so far: 到目前为止我尝试过的是:

I have looked into the ApplicationManager object, which allows you to bring an application to the foreground. 我已经研究了ApplicationManager对象,该对象使您可以将应用程序置于前台。 However when I use the following code to see what applications are available: 但是,当我使用以下代码查看可用的应用程序时:

ApplicationManager manager = ApplicationManager.getApplicationManager();
ApplicationDescriptor descriptors[] = manager.getVisibleApplications();
for(int i=0;i<descriptors.length;i++)
{
    String applicationName= descriptors[i].getName();
    System.out.println("applicationName");
}

The only visible applications are stuff like Phone, Messages, Blackberry Messages, Home Screen etc, but the options application is not present, which leads me to believe its not accessable from here. 唯一可见的应用程序是诸如“电话”,“消息”,“ Blackberry消息”,“主屏幕”之类的东西,但是没有选项应用程序,这使我相信无法从此处访问它。 (If I'm wrong please let me know) (如果我错了,请告诉我)

I have also taken a look at the Invoke.invokeApplication(appType, args) method, however the API does not have an appType constant for the options, or settings etc. The API specifies only the following types and I cannot find the one I need: 我也看过Invoke.invokeApplication(appType, args)方法,但是API没有用于选项或设置等的appType常量。API仅指定以下类型,而我找不到我需要的类型:

  • APP_TYPE_ADDRESSBOOK APP_TYPE_ADDRESSBOOK

  • APP_TYPE_BLUETOOTH_CONFIG APP_TYPE_BLUETOOTH_CONFIG

  • APP_TYPE_CALCULATOR APP_TYPE_CALCULATOR

  • APP_TYPE_CALENDAR APP_TYPE_CALENDAR

  • APP_TYPE_CAMERA APP_TYPE_CAMERA

  • APP_TYPE_MAPS APP_TYPE_MAPS

  • APP_TYPE_MEMOPAD APP_TYPE_MEMOPAD

  • APP_TYPE_MESSAGES APP_TYPE_MESSAGES

  • APP_TYPE_PHONE APP_TYPE_PHONE

  • APP_TYPE_SEARCH APP_TYPE_SEARCH

  • APP_TYPE_TASKS APP_TYPE_TASKS

I have scanned the API docs and I cannot find anything that looks right. 我已经扫描了API文档,但找不到任何看起来正确的东西。 Ive searched for Device and Options and Settings but none of the hits are relevant. 我已经搜索了“设备”,“选项和设置”,但没有任何相关内容。

If anyone knows what to do then let me know. 如果有人知道该怎么办,那就告诉我。

Unfortunately there's no standard API to invoke this screen programmatically. 不幸的是,没有标准的API以编程方式调用此屏幕。 But there's a workaround. 但是有一种解决方法。 Use EventInjector to inject a sequence of keyboard events to open Options screen. 使用EventInjector注入一系列键盘事件以打开“选项”屏幕。

This way is not an elegant one, but I think it is the only workaround in this case. 这种方法不是一种优雅的方法,但是我认为这是这种情况下的唯一解决方法。

UPDATE: 更新:

I would implement the following approach. 我将执行以下方法。 Upon application startup I would check, whether device is password protected via DeviceInfo.isPasswordEnabled() . 在应用程序启动时,我将检查设备是否通过DeviceInfo.isPasswordEnabled()受密码保护。

If device is not password protected I would display message: Device is not password protected. 如果设备不受密码保护,我会显示消息:设备不受密码保护。 Please set password for your device in the device Options. 请在设备选项中设置设备的密码。 And launch the application again. 并再次启动该应用程序。

I understand, this way is not elegant, but it is reliable and provides full information to the customers, how to use this application properly. 我了解,这种方式并不优雅,但可靠且可以向客户提供有关如何正确使用此应用程序的完整信息。

Ok so as it turns out you can run internal apps using the ApplicationManager , so I launched the Options app using the following code: 好的,事实证明您可以使用ApplicationManager来运行内部应用ApplicationManager ,因此我使用以下代码启动了Options应用程序:

  ApplicationManager.getApplicationManager().launch("net_rim_bb_options_app");

However this only launches the Options app, and does not navigate the user to the Security section. 但是,这只会启动“选项”应用程序,而不会将用户导航到“安全性”部分。

The following blurb from this page helped me understand what this method really does: 此页面上的以下内容帮助我了解了此方法的真正作用:

Starting 开始

A BlackBerry application can be started in a number of ways: BlackBerry应用程序可以通过多种方式启动:

  • by the system automatically on device startup 由系统在设备启动时自动
  • by another application 通过另一个应用程序
  • by the system at a scheduled time 由系统在预定的时间

Regardless of how an application is started, the Application Manager is responsible for starting the process the application will run within. 无论如何启动应用程序,应用程序管理器都负责启动应用程序将在其中运行的进程。

The ApplicationManager class enables applications to interact with the Application Manager to perform tasks, including: ApplicationManager类使应用程序可以与Application Manager交互以执行任务,包括:

  • run an application immediately or at a scheduled time 立即或在预定时间运行应用程序
  • interact with processes, including retrieving the IDs for foreground applications 与流程进行交互,包括检索前台应用程序的ID
  • post global events to the system 将全局事件发布到系统

Entry points 入口点

The Application Manager starts an application by getting a new process and spawning a thread within that process to call one of the entry points of the application. 应用程序管理器通过获取新进程并在该进程中产生一个线程来调用应用程序的入口点来启动应用程序。 For many applications, the main() method of its application class is the single entry point that is called. 对于许多应用程序,其应用程序类的main()方法是被调用的单个入口点。 But you can configure more than one entry point for an application. 但是您可以为一个应用程序配置多个入口点。

Using more than one entry point lets you create different ways for a user to start an application. 使用多个入口点可以使用户创建不同的方式来启动应用程序。 For example, if your application allows users to create a new document, you might like to provide users with two icons that they can click to start the application. 例如,如果您的应用程序允许用户创建新文档,则您可能想为用户提供两个图标,他们可以单击它们来启动应用程序。 Users could click one icon to open the application to its home screen and the other icon to open the application to the screen required to create a new document. 用户可以单击一个图标以将应用程序打开到其主屏幕,而单击另一个图标以将应用程序打开到创建新文档所需的屏幕。


Summary 摘要

So basically this method just runs the main method of the app, and supplies the arguments in the main method. 因此,基本上,此方法仅运行应用程序的main方法,并在main方法中提供参数。 It is my suspicion that the main method of the Options app does not allow for you to supply the page you want to open up on as an argument in the main method. 我怀疑Options应用程序的main方法不允许您提供要打开的页面作为main方法中的参数。

There is no documentation (as far as I can tell) on what arguments the options app takes, so short of guessing how it can be used, it seems that directing the user here and giving them some instructions on how to navigate further is my only option (据我所知)没有关于选项应用程序采用何种参数的文档,因此,我只是猜测如何使用它,似乎无法引导用户使用它,并向他们提供有关如何进一步导航的说明,这是我唯一的选择。选项

u_u u_u

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM