検索
メインメニュー
ログイン
ユーザー名:

パスワード:


パスワード紛失

新規登録

「アプリケーション センター」 - 開発者向けマニュアル


目次



はじめに

アプリケーション センター」は、有限会社シーリス "C-LIS CO., LTD." が開発したAndroidアプリです。

Androidのアプリケーションには、システムに常駐する。もしくは電話機の状態に応じて何らかの処理を行う等、ユーザーが操作するメインの画面を持たず、機能を設定する画面のみを持っている場合があります。これらのアプリをここでは、「システムツール系アプリ」と呼びます。

システムツール系アプリは、前述したとおり、機能を設定する画面しか持ちません。しかし、その場合でもホーム画面のメニューにアイコンが登録されます。

この構造では、次第にメニュー画面が混雑してしまい、ユーザーが、混雑したメニュー画面から目的のツールやアプリケーションを見つけることは難しくなります。

また、開発者にとっては、設定画面しか持たないシステムツール系アプリにもかかわらず、オリジナル・アイコンの作成をユーザーから求められるなど、開発の負担が増加する原因ともなっていました。

「アプリケーション センター」は、「システムツール系アプリ」の設定をまとめて、統一してアクセスするメニューを実現します。

各開発者は、サンプルコードを書き換えるだけで、「アプリケーション センター」にアプリケーションの設定画面を登録して、「アプリケーション センター」からツールの設定画面を呼び出すことが出来るようになります。

現在は、対応アプリケーションが限られていますが、将来的には、全てのAndroid端末に「アプリケーション センター」がインストールされ、各デベロッパーがツール系のアプリの設定画面への共通のアクセス手段として「アプリケーション センター」を利用する事を期待しています。


対応方法(開発者向)

META-DATAを利用する

setting_info.xmlを追加

プロジェクトのres/xmlディレクトリの下に、setting_info.xmlを作成します。

青文字の部分を変更してください。

<?xml version="1.0" encoding="utf-8"?>
<setting-provider xmlns:android="http://schemas.c-lis.co.jp/apk/res/android"
    android:label="@string/app_name"
    android:description="@string/settings_desc"
    android:package="org.sample.sampleapps"
    android:class="org.sample.sampleapps.SettingActivity"
    android:action="android.intent.action.VIEW"
    android:category="android.intent.category.DEFAULT"
    android:group="tool"
    />

<!--
group = tool | application | widget | game | blank
-->

設定アクティビティに<meta-data>を追加

<activity android:label="@string/app_name" android:name=".SettingActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    <meta-data android:name="jp.co.c_lis.provider.apps_settings" android:resource="@xml/setting_info" />
</activity>

方法2.BroadcastReceiverを利用する(非推奨)

この方法による実装は、現在は推奨されていません。新しく実装する際は、meta-dataによる実装をして下さい。

BroadcastReceiverの追加

BroadcastIntentのjp.co.c_lis.intent.action.RETRIEVE_SETTINGSを受け取る、BroadcastReceiverを追加します。

青文字の部分を変更してください。

/**
 * Sample BroadcastReceiver
 * 
 * This code will receive Intent ACTION "jp.co.c_lis.intent.action.RETRIEVE_SETTINGS"
 * 
 */
public class SettingRequestReceiver extends BroadcastReceiver {

	// const: Intent Keys definition
	private static final 	private static final String KEY_GROUP = "group";
	private static final String KEY_LABEL = "label";
	private static final String KEY_DESCRIPTION = "description";
	private static final String KEY_ACTION = "action";
	private static final String KEY_CATEGORY = "category";
	private static final String KEY_PACKAGE_NAME = "package";
	private static final String KEY_CLASS_NAME = "class";

	// const: Group definition
	private static final int GROUP_APPLICATION = 10;
	private static final int GROUP_TOOL = 20;
	private static final int GROUP_GAME = 30;
	private static final int GROUP_OTHERS = -1;

	/*
	 * (non-Javadoc)
	 * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
	 */
	@Override
	public void onReceive(Context context, Intent intent) {
		
		// Setting
		String packageName = "org.sample.sampleapps";
		String className= "org.sample.sampleapps.SettingActivity";
		String action = "android.intent.action.VIEW";
		String category = "android.intent.category.DEFAULT";
		String label = "Sample Setting Label";
		String description = "This is sample setting description.";
		int group = GROUP_TOOL;

		// Sending Intent
		Intent sendIntent = new Intent();

		sendIntent.setAction("jp.co.c_lis.intent.action.RESPONSE_SETTINGS");
		sendIntent.putExtra(KEY_LABEL, label);
		sendIntent.putExtra(KEY_DESCRIPTION, description);

		sendIntent.putExtra(KEY_PACKAGE_NAME, packageName);
		sendIntent.putExtra(KEY_CLASS_NAME, className);

		sendIntent.putExtra(KEY_ACTION, action);
		sendIntent.putExtra(KEY_CATEGORY, category);
		sendIntent.putExtra(KEY_GROUP, group);
		context.sendBroadcast(sendIntent);
	}
}

AndroidManifest.xmlに記述を追加

AndroidManifest.xmlに、BroadcastReceiverを登録します。また、設定アクティビティにBroadcastReceiver内で定義したIntentFilterを設定します。

	<activity android:name=".SettingActivity"
	          android:label="@string/app_name">
	    <intent-filter>
	        <action android:name="android.intent.action.VIEW" />
	        <category android:name="android.intent.category.DEFAULT" />
	    </intent-filter>
	</activity>
	<receiver android:name=".receiver.SettingRequestReceiver">
	    <intent-filter>
	        <action android:name="jp.co.c_lis.intent.action.RETRIEVE_SETTINGS" />
	    </intent-filter>
	</receiver>

サンプルコード

under construction


(2009/09/04 : META-DATAによる実装方法を追加) (2009/08/31 第一版)
プリンタ出力用画面
コンテンツ一覧
ヘッドライン
有限会社シーリス
Copyright© C-LIS CO., LTD. 2007-2010 All Rights Reserved.
Powered by XOOPS Cube 2.1© 2001-2006 XOOPS Cube Project