Taking screenshots

Additional Features (incl. taking screenshots) with Apphance instrumentation

Apphance instrumentation extends Apphance's device information to capture the following:
  • Application screenshots out-of-the-box.
  • Increased application state information
  • Additional debugging information

Enabling instrumentation requires few more steps in addition to regular integration. These are simply changes to the application's manifest file (AndroidManifest.xml).

Editing the application manifest


Step 1: Add LauncherActivity
  • Add a new LauncherActivity besides the two Apphance acitivities already present in the manifest:
<activity android:name="com.apphance.android.LauncherActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"></activity>

<activity android:name="com.apphance.android.ui.LoginActivity"></activity>
<activity android:name="com.apphance.android.ui.ProblemActivity"
            android:configChanges="orientation" android:launchMode="singleInstance"></activity>

Step 2: Add an activity-alias
  • Add an activity alias, making the new Apphance activity the starting point of your application.
<activity-alias android:name=".ApphanceLauncherActivity" android:targetActivity="com.apphance.android.LauncherActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity-alias>

Step 3: Modify the intent filter of your application's starting activity
  • Modify the intent filter of your original starting activity to look like the following (MainActivity is a placeholder for your actual activity name):
<activity android:name=".MainActivity">
    <intent-filter>
       <action android:name="com.apphance.android.LAUNCH"/>
       <category android:name="android.intent.category.DEFAULT"/>

    </intent-filter>    
</activity>

Step 4: Add Apphance instrumentation declaration
  • Under the <manifest> tag, add the following <instrumentation> declaration. Replace com.example with the actual package name of your application (as declared in package attribute of <manifest> tag):
<instrumentation android:name="com.apphance.android.ApphanceInstrumentation"
        android:targetPackage="com.example.REPLACE.THIS" />

Step 5: Add GET_TASKS permission
  • Add the GET_TASKS permission. This is necessary for Apphance to determine when your application has ended and needs to shutdown.
<uses-permission android:name="android.permission.GET_TASKS" />

(Note that currently there seems to be a bug in Eclipse ADT plugin, as it isn't detecting <activity-alias> as a valid target for the launcher intent. Therefore you will need to manually start your application from device menu after uploading it to the device via Eclipse).

Final form of the manifest

After applying changes listed above, your AndroidManifest.xml should look a lot like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="3" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
       
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="com.apphance.android.LAUNCH" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <!-- ... rest of your application's components -->
       
        <!-- Apphance activities -->
        <activity android:name="com.apphance.android.LauncherActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"></activity>
        <activity android:name="com.apphance.android.ui.LoginActivity" android:launchMode="singleInstance"></activity>
        <activity android:name="com.apphance.android.ui.ProblemActivity"
            android:configChanges="orientation" android:launchMode="singleInstance"></activity>
        <activity-alias android:name=".ApphanceLauncherActivity" android:targetActivity="com.apphance.android.LauncherActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity-alias>

    </application>
   
    <!-- Apphance instrumentation -->
    <instrumentation
        android:name="com.apphance.android.ApphanceInstrumentation"
        android:targetPackage="com.example" />
       
   
    <!-- Permissions required by Apphance -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.GET_TASKS" />
     
    <!-- ... rest of your application's permissions, if any -->
</manifest>


Comments