[英]Android Emulator not launching activity to foreground
I'm running an automated test in Eclipse using Robotium (running it as an Android jUnit test), when I first launch the emulator the app won't run in the foreground and the test fails. 我正在使用Robotium在Eclipse中运行自动化测试(将其作为Android jUnit测试运行),当我首次启动模拟器时,该应用程序不会在前台运行,并且测试失败。 If I keep the emulator open press the 'main menu' button then run the test it works fine. 如果我保持模拟器处于打开状态,请按“主菜单”按钮,然后运行测试即可正常运行。 The test is running a few events in a test project which is a notepad. 该测试正在一个记事本的测试项目中运行一些事件。
Any solutions to pushing the app to the foreground when it first opens the emulator? 在首次打开模拟器时将应用程序推到前台的任何解决方案?
Here's the manifest from the Test Project 这是测试项目的清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jayway.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-library android:name="android.test.runner" />
Here's the manifest from the actual project 这是实际项目的清单
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.notepad" >
<application android:icon="@drawable/app_notes"
android:label="@string/app_name" >
<provider android:name="NotePadProvider"
android:authorities="com.example.notepad.provider.NotePad" />
<activity android:name="NotesList"
android:label="@string/title_notes_list">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>
</activity>
<activity android:name="NoteEditor"
android:theme="@android:style/Theme.Light"
android:configChanges="keyboardHidden|orientation">
<!-- This filter says that we can view or edit the data of
a single note -->
<intent-filter android:label="@string/resolve_edit">
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="com.android.notes.action.EDIT_NOTE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>
</activity>
<activity android:name="NotesLiveFolder" android:label="@string/live_folder_name"
android:icon="@drawable/live_folder_notes">
<intent-filter>
<action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="10"/>
</manifest>
</application>
<uses-sdk android:minSdkVersion="10" />
<instrumentation android:targetPackage="com.example.android.notepad" android:name="android.test.InstrumentationTestRunner" />
</manifest>
I solved this using this command. 我使用此命令解决了这个问题。
adb shell input keyevent 82 亚行外壳输入keyevent 82
This wakes the emulator/device. 这将唤醒仿真器/设备。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.