From wiki.ginstr.com
Jump to: navigation, search

Integrating ginstr logo main.png launcher as HelpOverlay into client Android app

ginstr launcher can be also used as a library and initialised within another Android project as an activity.

In order to do so, an Android client app needs to follow necessary steps to enable ginstr launcher’s functioning as a library within a client project.

Implementation steps of ginstr launcher into client Android app

Eclipse version of integration

To integrate ginstr launcher in client application three projects are necessary :

  1. ginstr launcher
  2. GnExampleClient
  3. GnStorageServiceApi

After importing these projects into Eclipse workspace, follow the steps below.

Setting ginstr launcher to be library project

Screenshot 1. Properties of ginstr launcher
  • Right click “ginstr launcher” project and click “Build path
  • Click “Configure Build Path”.
  • A window will appear “Properties for ginstr launcher”.
  • Select “Android” from list on left side.
  • Select “Is Library” checkbox. Below is a list of referenced projects.
  • Remove all from list if more and leave only “GnStorageServiceApi”.
  • The screen should look like Screenshot 1 (shown right).
  • Click “Apply” and “OK” when completed.

Setting up ginstr launcher as library of “GnExampleClient”:

Screenshot 2. Library projects of GnExampleClient

Right click “GnExampleClient” and select “Build path” -> “Configure Build Path”.

In the window “Properties for GnExampleClient” select “Android” in the list on the left.

On the right side under the checkbox “Is Library” is a button “Add”, click it and select “ginstr launcher” (if the ginstr launcher is not shown in the selection list make sure step one was completed).

Manifest changes in “GnExampleClient”

To avoid any errors and to provide ginstr launcher with all permissions necessary to open GnExampleClient.xml and complete the following changes to manifest.

Minimum SDK version (within <manifest></manifest> element):

<uses-sdk
    android:minSdkVersion="10"
    android:targetSdkVersion="17" />

Add permissions (within <manifest></manifest> element):

<uses-feature
    android:name="android.hardware.camera"
    android:required="false" />
<uses-feature
    android:name="android.hardware.nfc"
    android:required="false" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.NFC" />

Add activities and services (within <application></application> element):

<activity android:name="com.ginstr.activities.PreferencesActivity" />
<activity android:name="com.ginstr.activities.MainActivityAG" />
<activity
   android:name="com.ginstr.layout.LayoutActivity"
   android:configChanges="orientation/screenSize"
   android:theme="@android:stle/Theme.Black.NoTitleBar" />

<service android:name="com.ginstr.storage.local.StorageServiceSQLLite" />
<service android:name="com.ginstr.storage.remote.StorageServiceServerGateway" />

Add configuration for ginstr launcher (within <application></application> element):

<meta-data
    android:name="HOMode"
    android:value="true" />

Copying assets from ginstr launcher to GnExampleClient

Screenshot 3. Assets folder in client

Assets need to be copied from ginstr launcher project folder assets to GnExampleClient assets folder.

Copy files from folder ginstr launcher/assets/:

  • activity.xml
  • start.xml
  • strings.xml

To folder GnExampleClient/assets/.

The resulting structure should look as per Screenshot 3 (shown right)

Starting ginstr launcher from GnExampleClient

Everything is now ready to launch ginstr launcher within a client app.

ginstr launcher is launched as a new activity so the following code can be used:

public class MainActivity extends Activity {

   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);

       Button btnOpenAg = (Button) findViewById(R.id.startAppGenerator);
       btnOpenAg.setOnClickListener(new OnClickListener() {
           @Override
           public void onClick(Ciew v) {
               Intent i = new Intent(getApplicationContext(),MainActivityAG.class); startActivity(i);
           }
       });
   }