I completed the "Configuring Push Notification" part of the Esri geotrigger for Android. However, I keep getting the "unable to load device" error. What could be the reasons for getting this error?
The error appears after running this method:
GeotriggerService.init(context, CLIENT_ID, GCM_SENDER_ID, GeotriggerService.TRACKING_PROFILE_ADAPTIVE); JSONObject params = new JSONObject(); try { params.put("text", "Push notifications are working!"); params.put("url", "http://developers.arcgis.com"); } catch (JSONException e) { Log.e(TAG, "Error creating device/notify params", e); } GeotriggerApiClient.runRequest(context, "device/notify", params, new GeotriggerApiListener() { @Override public void onSuccess(JSONObject json) { Log.i(TAG, "device/notify success: " + json); } @Override public void onFailure(Throwable error) { Log.e(TAG, "device/notify failure", error); } });And my manifest.xml file looks like this:
"
Here's a copy of the main activity:
package com.elikemkuivi.fashionstreet;import android.app.SearchManager;import android.content.Context;import android.content.Intent;import android.content.SharedPreferences;import android.content.res.Resources;import android.os.Bundle;import android.support.v7.app.ActionBarActivity;import android.support.v7.widget.SearchView;import android.util.Log;import android.view.Menu;import android.view.MenuInflater;import android.view.MenuItem;import android.view.View;import android.widget.AdapterView;import android.widget.AdapterView.OnItemClickListener;import android.widget.GridView;import android.widget.ListView;import android.widget.ProgressBar;import android.widget.TextView;import com.esri.android.geotrigger.GeotriggerApiClient;import com.esri.android.geotrigger.GeotriggerApiListener;import com.esri.android.geotrigger.GeotriggerService;import com.google.android.gms.gcm.GoogleCloudMessaging;import org.json.JSONException;import org.json.JSONObject;import java.util.ArrayList;import java.util.concurrent.atomic.AtomicInteger;public class ShopListActivity extends ActionBarActivity implements SearchView.OnQueryTextListener { protected Context context; protected String[] mShops; protected String[] mCategory_names; protected String[] mLocate_shops_names; protected String[] mWebsites; protected GridView mGridView; protected ListView mListView; protected ProgressBar mProgressBar; protected TextView emptyTextView; protected ShopLayoutAdapter adapter; protected ArrayList shops_arrlist = new ArrayList(); protected String CLIENT_ID = "Q0bPdyhOItoWPBTw"; protected final String GCM_SENDER_ID = "851435869460"; protected final String TAG = ShopListActivity.class.getSimpleName(); protected final static int PLAY_SERVICES_RESOLUTION_REQUEST = 9000; public final static String EXTRA_MESSAGE = "message"; public static final String PROPERTY_REG_ID = "registration_id"; protected static final String PROPERTY_APP_VERSION = "appVersion"; String SENDER_ID = "851435869460"; static final String GCM_TAG = "GCM"; TextView mDisplay; GoogleCloudMessaging gcm; AtomicInteger msgId = new AtomicInteger(); SharedPreferences prefs; String regid; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_shop_list); Intent i = getIntent(); // mGridView = (GridView) findViewById(R.id.shops_grid); mListView = (ListView) findViewById(R.id.shoplistView1); mProgressBar = (ProgressBar) findViewById(R.id.progressBar2); Resources resource = getResources(); mCategory_names = resource.getStringArray(R.array.category_names); mWebsites = resource.getStringArray(R.array.websites); mShops = resource.getStringArray(R.array.list_shops); for(int index = 0; index < mShops.length; index ++){ Log.i("ShopListActivity", "Here!!! " + mShops[index]); shops_arrlist.add(mShops[index]); } mLocate_shops_names = resource .getStringArray(R.array.locate_shops_names); emptyTextView = (TextView) findViewById(android.R.id.empty); context = getApplicationContext(); //Check device for Play Services APK. If check succeeds, proceed with // GCM registration. /** if(checkPlayServices()){ gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(context); if(regid.isEmpty()){ registerInBackground register = new registerInBackground(); register.execute(); } } else{ Log.i(GCM_TAG, "No valid Google Play Services APK found."); } */ GeotriggerService.init(context, CLIENT_ID, GCM_SENDER_ID, GeotriggerService.TRACKING_PROFILE_ADAPTIVE); JSONObject params = new JSONObject(); try { params.put("text", "Push notifications are working!"); params.put("url", "http://developers.arcgis.com"); } catch (JSONException e) { Log.e(TAG, "Error creating device/notify params", e); } GeotriggerApiClient.runRequest(context, "device/notify", params, new GeotriggerApiListener() { @Override public void onSuccess(JSONObject json) { Log.i(TAG, "device/notify success: " + json); } @Override public void onFailure(Throwable error) { Log.e(TAG, "device/notify failure", error); } }); handleIntent(i); } /** * Check the device to make sure it has the Google Play Services APK. If * it doesn't, display a dialog that allows users to download the APK from * the Google Play Store or enable it in the device's system settings. */ /* protected boolean checkPlayServices(){ int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if(resultCode != ConnectionResult.SUCCESS){ if(GooglePlayServicesUtil.isUserRecoverableError(resultCode)){ GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else{ Log.i(TAG, "This device is not supported"); finish(); } return false; } return true; } */ /** * Gets the current registration ID for application on GCM service. *
* If result is empty, the app needs to register. * * @return registration ID, or empty string if there is no existing * registration ID. */ /* protected String getRegistrationId(Context context){ final SharedPreferences prefs = getGCMPreferences(context); String registrationId = prefs.getString(PROPERTY_REG_ID, ""); if(registrationId.isEmpty()){ Log.i(GCM_TAG, "Registration not found"); return ""; } // Check if app was updated; if so, it must clear the registration ID // since the existing registration ID is not guaranteed to work with // the new app version. int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE); int currentVersion = getAppVersion(context); if(registeredVersion != currentVersion){ Log.i(GCM_TAG, "App Version changed."); return ""; } return registrationId; } */ /** * @return Application's {@code SharedPreferences}. */ /* protected SharedPreferences getGCMPreferences(Context context) { // This sample app persists the registration ID in shared preferences, but // how you store the registration ID in your app is up to you. return getSharedPreferences(TAG, Context.MODE_PRIVATE); } */ /** * @return Application's version code from the {@code PackageManager}. */ /* protected static int getAppVersion(Context context){ try{ PackageInfo packageInfo = context.getPackageManager() .getPackageInfo(context.getPackageName(), 0); return packageInfo.versionCode; } catch(PackageManager.NameNotFoundException e){ //should never happen throw new RuntimeException("Could not get package name: " + e); } } */ /** * Registers the application with GCM servers asynchronously. *
* Stores the registration ID and app versionCode in the application's * shared preferences. */ /* protected class registerInBackground extends AsyncTask { @Override protected String doInBackground(Void... params) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration ID=" + regid; // You should send the registration ID to your server over HTTP, // so it can use GCM/HTTP or CCS to send messages to your app. // The request to your server should be authenticated if your app // is using accounts. sendRegistrationIdToBackend(); // For this demo: we don't need to send it because the device // will send upstream messages to a server that echo back the // message using the 'from' address in the message. // Persist the registration ID - no need to register again. storeRegistrationId(context, regid); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); // If there is an error, don't just keep trying to register. // Require the user to click a button again, or perform // exponential back-off. } return msg; } @Override protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } } */ /** * Sends the registration ID to your server over HTTP, so it can use GCM/HTTP * or CCS to send messages to your app. Not needed for this demo since the * device sends upstream messages to a server that echoes back the message * using the 'from' address in the message. */ /* protected void sendRegistrationIdToBackend() { // Your implementation here. } */ /** * Stores the registration ID and app versionCode in the application's * {@code SharedPreferences}. * * @param * @param */ /* protected void storeRegistrationId(Context context, String regId){ final SharedPreferences prefs = getGCMPreferences(context); int appVersion = getAppVersion(context); Log.i(GCM_TAG, "Saving regId on app version " + appVersion); SharedPreferences.Editor editor = prefs.edit(); editor.putString(PROPERTY_REG_ID, regId); editor.putInt(PROPERTY_APP_VERSION, appVersion); editor.commit(); } */ private void handleIntent(Intent i) { if (Intent.ACTION_SEARCH.equals(i.getAction())) { String query = i.getStringExtra(SearchManager.QUERY); Log.i("Search Activated", "SEARCH!!!!!"); //doMySearch(query); // use the query to search your data somehow } else { adapter = new ShopLayoutAdapter(this,shops_arrlist); mProgressBar.setVisibility(View.VISIBLE); // mGridView.setAdapter(adapter); mListView.setAdapter(adapter); mListView.setEmptyView(emptyTextView); mProgressBar.setVisibility(View.INVISIBLE); mListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { String category_name = mCategory_names[position]; Intent intent = new Intent(ShopListActivity.this, MainListActivity.class); intent.putExtra("category_name", category_name); intent.putExtra("real_shop_name", mLocate_shops_names[position]); intent.putExtra("toast_notification", mShops[position]); intent.putExtra("shop_website", mWebsites[position]); startActivity(intent); } }); } } /** private void doMySearch(String query) { String search_results = ""; int num_results = 0; for(int i = 0; i < mShops.length; i++){ if (mShops.indexOf(query) > -1 && num_results == 0) { search_results = mShops; num_results ++; } else if (mShops.indexOf(query) > -1 && num_results > 0) { search_results = search_results + "|" + mShops; num_results++; } } if(search_results.length() > 0){ ArrayList results_arr = search_results.split("|"); adapter = new ShopLayoutAdapter(this, results_arr); mListView.setAdapter(adapter); mListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { String category_name = mCategory_names[position]; Intent intent = new Intent(ShopListActivity.this, MainListActivity.class); intent.putExtra("category_name", category_name); intent.putExtra("real_shop_name", mLocate_shops_names[position]); intent.putExtra("toast_notification", mShops[position]); intent.putExtra("shop_website", mWebsites[position]); startActivity(intent); } }); } else mListView.setEmptyView(emptyTextView); } */ /* @Override protected void onGridItemClick(GridView l, View v, int position, long id) { super.onGridItemClick(l, v, position, id); String category_name = mCategory_names[position]; Intent intent = new Intent(this, MainListActivity.class); intent.putExtra("category_name", category_name); startActivity(intent); }*/ @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.shop_list, menu); //MenuItem searchItem = menu.findItem(R.id.action_search); //SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); // Assumes current activity is the searchable activity searchView.setQueryHint(getResources().getString(R.string.search_hint)); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default searchView.setOnQueryTextListener(this); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if(id == R.id.action_help){ Intent intent = new Intent(this, HelpActivity.class); startActivity(intent); } else if(id == R.id.action_contact_us){ Intent intent = new Intent(this, ContactActivity.class); startActivity(intent); } else if(id == R.id.action_search){ onSearchRequested(); } return super.onOptionsItemSelected(item); } @Override protected void onNewIntent(Intent intent) { handleIntent(intent); } @Override public boolean onQueryTextChange(String arg0) { Log.i("QueryChange", "Change!!!!" + arg0); adapter.getFilter().filter(arg0.toString()); return true; } @Override public boolean onQueryTextSubmit(String arg0) { return false; } /* @Override protected void onResume(){ super.onResume(); checkPlayServices(); } */}
أكثر...
The error appears after running this method:
GeotriggerService.init(context, CLIENT_ID, GCM_SENDER_ID, GeotriggerService.TRACKING_PROFILE_ADAPTIVE); JSONObject params = new JSONObject(); try { params.put("text", "Push notifications are working!"); params.put("url", "http://developers.arcgis.com"); } catch (JSONException e) { Log.e(TAG, "Error creating device/notify params", e); } GeotriggerApiClient.runRequest(context, "device/notify", params, new GeotriggerApiListener() { @Override public void onSuccess(JSONObject json) { Log.i(TAG, "device/notify success: " + json); } @Override public void onFailure(Throwable error) { Log.e(TAG, "device/notify failure", error); } });And my manifest.xml file looks like this:
"
Here's a copy of the main activity:
package com.elikemkuivi.fashionstreet;import android.app.SearchManager;import android.content.Context;import android.content.Intent;import android.content.SharedPreferences;import android.content.res.Resources;import android.os.Bundle;import android.support.v7.app.ActionBarActivity;import android.support.v7.widget.SearchView;import android.util.Log;import android.view.Menu;import android.view.MenuInflater;import android.view.MenuItem;import android.view.View;import android.widget.AdapterView;import android.widget.AdapterView.OnItemClickListener;import android.widget.GridView;import android.widget.ListView;import android.widget.ProgressBar;import android.widget.TextView;import com.esri.android.geotrigger.GeotriggerApiClient;import com.esri.android.geotrigger.GeotriggerApiListener;import com.esri.android.geotrigger.GeotriggerService;import com.google.android.gms.gcm.GoogleCloudMessaging;import org.json.JSONException;import org.json.JSONObject;import java.util.ArrayList;import java.util.concurrent.atomic.AtomicInteger;public class ShopListActivity extends ActionBarActivity implements SearchView.OnQueryTextListener { protected Context context; protected String[] mShops; protected String[] mCategory_names; protected String[] mLocate_shops_names; protected String[] mWebsites; protected GridView mGridView; protected ListView mListView; protected ProgressBar mProgressBar; protected TextView emptyTextView; protected ShopLayoutAdapter adapter; protected ArrayList shops_arrlist = new ArrayList(); protected String CLIENT_ID = "Q0bPdyhOItoWPBTw"; protected final String GCM_SENDER_ID = "851435869460"; protected final String TAG = ShopListActivity.class.getSimpleName(); protected final static int PLAY_SERVICES_RESOLUTION_REQUEST = 9000; public final static String EXTRA_MESSAGE = "message"; public static final String PROPERTY_REG_ID = "registration_id"; protected static final String PROPERTY_APP_VERSION = "appVersion"; String SENDER_ID = "851435869460"; static final String GCM_TAG = "GCM"; TextView mDisplay; GoogleCloudMessaging gcm; AtomicInteger msgId = new AtomicInteger(); SharedPreferences prefs; String regid; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_shop_list); Intent i = getIntent(); // mGridView = (GridView) findViewById(R.id.shops_grid); mListView = (ListView) findViewById(R.id.shoplistView1); mProgressBar = (ProgressBar) findViewById(R.id.progressBar2); Resources resource = getResources(); mCategory_names = resource.getStringArray(R.array.category_names); mWebsites = resource.getStringArray(R.array.websites); mShops = resource.getStringArray(R.array.list_shops); for(int index = 0; index < mShops.length; index ++){ Log.i("ShopListActivity", "Here!!! " + mShops[index]); shops_arrlist.add(mShops[index]); } mLocate_shops_names = resource .getStringArray(R.array.locate_shops_names); emptyTextView = (TextView) findViewById(android.R.id.empty); context = getApplicationContext(); //Check device for Play Services APK. If check succeeds, proceed with // GCM registration. /** if(checkPlayServices()){ gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(context); if(regid.isEmpty()){ registerInBackground register = new registerInBackground(); register.execute(); } } else{ Log.i(GCM_TAG, "No valid Google Play Services APK found."); } */ GeotriggerService.init(context, CLIENT_ID, GCM_SENDER_ID, GeotriggerService.TRACKING_PROFILE_ADAPTIVE); JSONObject params = new JSONObject(); try { params.put("text", "Push notifications are working!"); params.put("url", "http://developers.arcgis.com"); } catch (JSONException e) { Log.e(TAG, "Error creating device/notify params", e); } GeotriggerApiClient.runRequest(context, "device/notify", params, new GeotriggerApiListener() { @Override public void onSuccess(JSONObject json) { Log.i(TAG, "device/notify success: " + json); } @Override public void onFailure(Throwable error) { Log.e(TAG, "device/notify failure", error); } }); handleIntent(i); } /** * Check the device to make sure it has the Google Play Services APK. If * it doesn't, display a dialog that allows users to download the APK from * the Google Play Store or enable it in the device's system settings. */ /* protected boolean checkPlayServices(){ int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if(resultCode != ConnectionResult.SUCCESS){ if(GooglePlayServicesUtil.isUserRecoverableError(resultCode)){ GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } else{ Log.i(TAG, "This device is not supported"); finish(); } return false; } return true; } */ /** * Gets the current registration ID for application on GCM service. *
* If result is empty, the app needs to register. * * @return registration ID, or empty string if there is no existing * registration ID. */ /* protected String getRegistrationId(Context context){ final SharedPreferences prefs = getGCMPreferences(context); String registrationId = prefs.getString(PROPERTY_REG_ID, ""); if(registrationId.isEmpty()){ Log.i(GCM_TAG, "Registration not found"); return ""; } // Check if app was updated; if so, it must clear the registration ID // since the existing registration ID is not guaranteed to work with // the new app version. int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE); int currentVersion = getAppVersion(context); if(registeredVersion != currentVersion){ Log.i(GCM_TAG, "App Version changed."); return ""; } return registrationId; } */ /** * @return Application's {@code SharedPreferences}. */ /* protected SharedPreferences getGCMPreferences(Context context) { // This sample app persists the registration ID in shared preferences, but // how you store the registration ID in your app is up to you. return getSharedPreferences(TAG, Context.MODE_PRIVATE); } */ /** * @return Application's version code from the {@code PackageManager}. */ /* protected static int getAppVersion(Context context){ try{ PackageInfo packageInfo = context.getPackageManager() .getPackageInfo(context.getPackageName(), 0); return packageInfo.versionCode; } catch(PackageManager.NameNotFoundException e){ //should never happen throw new RuntimeException("Could not get package name: " + e); } } */ /** * Registers the application with GCM servers asynchronously. *
* Stores the registration ID and app versionCode in the application's * shared preferences. */ /* protected class registerInBackground extends AsyncTask { @Override protected String doInBackground(Void... params) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration ID=" + regid; // You should send the registration ID to your server over HTTP, // so it can use GCM/HTTP or CCS to send messages to your app. // The request to your server should be authenticated if your app // is using accounts. sendRegistrationIdToBackend(); // For this demo: we don't need to send it because the device // will send upstream messages to a server that echo back the // message using the 'from' address in the message. // Persist the registration ID - no need to register again. storeRegistrationId(context, regid); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); // If there is an error, don't just keep trying to register. // Require the user to click a button again, or perform // exponential back-off. } return msg; } @Override protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } } */ /** * Sends the registration ID to your server over HTTP, so it can use GCM/HTTP * or CCS to send messages to your app. Not needed for this demo since the * device sends upstream messages to a server that echoes back the message * using the 'from' address in the message. */ /* protected void sendRegistrationIdToBackend() { // Your implementation here. } */ /** * Stores the registration ID and app versionCode in the application's * {@code SharedPreferences}. * * @param * @param */ /* protected void storeRegistrationId(Context context, String regId){ final SharedPreferences prefs = getGCMPreferences(context); int appVersion = getAppVersion(context); Log.i(GCM_TAG, "Saving regId on app version " + appVersion); SharedPreferences.Editor editor = prefs.edit(); editor.putString(PROPERTY_REG_ID, regId); editor.putInt(PROPERTY_APP_VERSION, appVersion); editor.commit(); } */ private void handleIntent(Intent i) { if (Intent.ACTION_SEARCH.equals(i.getAction())) { String query = i.getStringExtra(SearchManager.QUERY); Log.i("Search Activated", "SEARCH!!!!!"); //doMySearch(query); // use the query to search your data somehow } else { adapter = new ShopLayoutAdapter(this,shops_arrlist); mProgressBar.setVisibility(View.VISIBLE); // mGridView.setAdapter(adapter); mListView.setAdapter(adapter); mListView.setEmptyView(emptyTextView); mProgressBar.setVisibility(View.INVISIBLE); mListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { String category_name = mCategory_names[position]; Intent intent = new Intent(ShopListActivity.this, MainListActivity.class); intent.putExtra("category_name", category_name); intent.putExtra("real_shop_name", mLocate_shops_names[position]); intent.putExtra("toast_notification", mShops[position]); intent.putExtra("shop_website", mWebsites[position]); startActivity(intent); } }); } } /** private void doMySearch(String query) { String search_results = ""; int num_results = 0; for(int i = 0; i < mShops.length; i++){ if (mShops.indexOf(query) > -1 && num_results == 0) { search_results = mShops; num_results ++; } else if (mShops.indexOf(query) > -1 && num_results > 0) { search_results = search_results + "|" + mShops; num_results++; } } if(search_results.length() > 0){ ArrayList results_arr = search_results.split("|"); adapter = new ShopLayoutAdapter(this, results_arr); mListView.setAdapter(adapter); mListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { String category_name = mCategory_names[position]; Intent intent = new Intent(ShopListActivity.this, MainListActivity.class); intent.putExtra("category_name", category_name); intent.putExtra("real_shop_name", mLocate_shops_names[position]); intent.putExtra("toast_notification", mShops[position]); intent.putExtra("shop_website", mWebsites[position]); startActivity(intent); } }); } else mListView.setEmptyView(emptyTextView); } */ /* @Override protected void onGridItemClick(GridView l, View v, int position, long id) { super.onGridItemClick(l, v, position, id); String category_name = mCategory_names[position]; Intent intent = new Intent(this, MainListActivity.class); intent.putExtra("category_name", category_name); startActivity(intent); }*/ @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.shop_list, menu); //MenuItem searchItem = menu.findItem(R.id.action_search); //SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); // Assumes current activity is the searchable activity searchView.setQueryHint(getResources().getString(R.string.search_hint)); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default searchView.setOnQueryTextListener(this); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if(id == R.id.action_help){ Intent intent = new Intent(this, HelpActivity.class); startActivity(intent); } else if(id == R.id.action_contact_us){ Intent intent = new Intent(this, ContactActivity.class); startActivity(intent); } else if(id == R.id.action_search){ onSearchRequested(); } return super.onOptionsItemSelected(item); } @Override protected void onNewIntent(Intent intent) { handleIntent(intent); } @Override public boolean onQueryTextChange(String arg0) { Log.i("QueryChange", "Change!!!!" + arg0); adapter.getFilter().filter(arg0.toString()); return true; } @Override public boolean onQueryTextSubmit(String arg0) { return false; } /* @Override protected void onResume(){ super.onResume(); checkPlayServices(); } */}
أكثر...