java - NullPointerException on getAction( ) or Intent -


i wanted utilize search view widget in action bar google places api , stumbled upon link tutorial shared in various posts on stack overflow, decided check out. have implemented existing code, getting nullpointerexception , hoping can me out bit, can debug issue. i've been browsing through various posts on stack overflow , articles via google...

logcat specifies caused lines 119 , 123.

mainactivity.java:

public class mainactivity extends fragmentactivity implements googleplayservicesclient.connectioncallbacks, googleplayservicesclient.onconnectionfailedlistener, locationlistener, onmaplongclicklistener, loadercallbacks<cursor> {  //global constants private final static int connection_failure_resolution_request = 9000;  // milliseconds per second private static final int milliseconds_per_second = 1000; // update frequency in seconds public static final int update_interval_in_seconds = 5; // update frequency in milliseconds private static final long update_interval =         milliseconds_per_second * update_interval_in_seconds; // fastest update frequency, in seconds private static final int fastest_interval_in_seconds = 1; // fast frequency ceiling in milliseconds private static final long fastest_interval =         milliseconds_per_second * fastest_interval_in_seconds;   //global variables googlemap map; marker marker; locationrequest requestlocation; locationclient locationclient; locationmanager locationmanager; boolean updatesrequested; geofence geofence; vibrator vibstatus;   @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      // create locationrequest object     requestlocation = locationrequest.create();     // use high accuracy     requestlocation.setpriority(             locationrequest.priority_high_accuracy);     // set update interval 5 seconds     requestlocation.setinterval(update_interval);     // set fastest update interval 1 second     requestlocation.setfastestinterval(fastest_interval);       supportmapfragment fragment = (supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map);     map = fragment.getmap();      //enables "my location" button on map fragment     map.getuisettings().setmylocationbuttonenabled(true);      //create new location client, using enclosing class handle callbacks.     locationclient = new locationclient(this, this, this);     // start updates turned off     updatesrequested = false;      //     map.setonmaplongclicklistener(this);      // adview resource , load request.     adview adview = (adview)this.findviewbyid(r.id.adview);     adrequest adrequest = new adrequest.builder().build();     adview.loadad(adrequest);      handleintent(getintent()); //this line 119 in code   }  private void handleintent(intent intent){     if(intent.getaction().equals(intent.action_search)){ //this line 123 in code         dosearch(intent.getstringextra(searchmanager.query));     }else if(intent.getaction().equals(intent.action_view)){         getplace(intent.getstringextra(searchmanager.extra_data_key));     } }  @override protected void onnewintent(intent intent) {     super.onnewintent(intent);     setintent(intent);     handleintent(intent); } ... } 

androidmanifest.xml:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com...." //removed while posting on forum android:versioncode="1" android:versionname="1.0" >  <uses-sdk     android:minsdkversion="10"     android:targetsdkversion="19" />  <!-- protect map component of application using application signature --> <permission     android:name="com.....permission.maps_receive" //removed while posting on forum     android:protectionlevel="signature" />  <!-- allows receive map --> <uses-permission android:name="com.....permission.maps_receive" /> //removed while posting on forum  <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="android.permission.vibrate" />  <uses-feature     android:glesversion="0x00020000"     android:required="true" />  <application     android:allowbackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/theme.appcompat.light.darkactionbar" >     <activity         android:name="com.....splashactivity" //removed while posting on forum         android:label="@string/app_name"         android:screenorientation="portrait" >         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>     <activity         android:name="com.....mainactivity" //removed while posting on forum         android:label="@string/app_name"         android:launchmode="singletop"         android:screenorientation="portrait" >         <intent-filter>             <action android:name="android.intent.action.search" />         </intent-filter>         <!-- points searchable activity -->         <meta-data android:name="android.app.default_searchable"             android:value="com.....mainactivity" /> //removed while posting on forum          <!-- points searchable meta data -->         <meta-data android:name="android.app.searchable"             android:resource="@xml/searchable"/>     </activity>      <activity         android:name="com.....preferencesactivity" //removed while posting on forum         android:label="@string/title_activity_settings"         android:parentactivityname="com.....mainactivity" //removed while posting on forum         android:screenorientation="portrait" >         <meta-data             android:name="android.support.parent_activity"             android:value="com.....mainactivity" /> //removed while posting on forum     </activity>     <activity         android:name="com.....alarmactivity" //removed while posting on forum         android:label="@string/title_activity_alarm" >     </activity>     <activity         android:name="com.google.android.gms.ads.adactivity"         android:configchanges="keyboard|keyboardhidden|orientation|screenlayout|uimode|screensize|smallestscreensize" />     <activity         android:name="com.....placejsonparser" //removed while posting on forum         android:label="@string/title_activity_place_jsonparser" >     </activity>     <activity         android:name="com.....placedetailsjsonparser" //removed while posting on forum         android:label="@string/title_activity_place_details_jsonparser" >     </activity>     <activity         android:name="com.....placeprovider" //removed while posting on forum         android:label="@string/title_activity_place_provider" >     </activity>       <provider         android:name=".placeprovider"         android:authorities="com.....placeprovider" //removed while posting on forum         android:exported="false" />      <meta-data         android:name="com.google.android.gms.version"         android:value="@integer/google_play_services_version" />     <meta-data         android:name="com.google.android.maps.v2.api_key"         android:value="my-key-here" /> //removed while posting on forum  </application>  </manifest> 

you starting mainactivity splashactivity? when happens in search view? looks it. when call startactivity(intent), need make sure have added action intent:

intent mainactivityintent = new intent(context); mainactivityintent.setaction(intent.action_search); startactivity(mainactivityintent); 

if you, or whatever calls mainactivity using intent, doesn't set action on intent, going null pointer when try getaction() on calling intent in activity.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -