******これは私の Android manifest.xml での Activity の実装です*****
<activity
android:name="com.zameen.zameenapp.GizmosActivity"
android:label="@string/title_gizmos" >
<intent-filter android:label="@string/filter_title_viewgizmos">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/gizmos" />
<!-- note that the leading "/" is required for pathPrefix-->
<!-- Accepts URIs that begin with "example://gizmos”
<data android:scheme="example"
android:host="gizmos" />
-->
</intent-filter>
</activity>
これは私のアクティビティクラスです
package com.zameen.zameenapp;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;
import android.app.Activity;
import android.content.Intent;
import android.drm.DrmStore.Action;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
public class GizmosActivity extends Activity
{
static final Uri APP_URI = Uri.parse("android-app://com.zameen.zameenapp/http/www.example.com/gizmos");
static final Uri WEB_URL = Uri.parse("http://www.example.com/gizmos/");
private GoogleApiClient mClient;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_side_menu);
mClient = new GoogleApiClient.Builder(this).addApi(AppIndex.APP_INDEX_API).build();
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
}
@Override
public void onStart() {
super.onStart();
// Connect your client
mClient.connect();
// Define a title for your current page, shown in autocompletion UI
String title = "App Indexing API Title";
// Construct the Action performed by the user
Action viewAction = Action.newAction(Action.TYPE_VIEW, title, WEB_URL, APP_URI);
// Call the App Indexing API start method after the view has completely rendered
AppIndex.AppIndexApi.start(mClient, viewAction);
}
@Override
public void onStop() {
// Call end() and disconnect the client
String title = "App Indexing API Title";
Action viewAction = Action.newAction(Action.TYPE_VIEW, title, WEB_URL, APP_URI);
AppIndex.AppIndexApi.end(mClient, viewAction);
mClient.disconnect();
super.onStop();
}
}
私は自分のアプリに Google インデックスを実装しています。www.example.com/gizmos という特定の URL で、adb コマンド ラインを使用して簡単にアクティビティを開始できることを確認済みです。問題は、import com.google.android.gms.appindexing.Action;である Action Class Library ファイルをインポートする必要があることです。 しかし、追加しようとするたびにエラーが発生し、Eclipse の推奨に従って所定のライブラリ ファイルをインポートすると、AppIndex.AppIndexApi.endとnewAction(Action.TYPE_VIEW, title, WEB_URL, APP_URI); でエラーが発生します。問題を解決できる GizmosActivity の Action クラスのライブラリ ファイルをインポートしたい。そして、うまく機能しているかどうかをテストするにはどうすればよいですか?解決策を高く評価します