This question already has answers here:
After Google Play Service update to version 13 I got an error
(8 answers)
Closed 9 years ago.
Yesterday I updated my eclipse. Before I update the eclipse, my application ran correctly but after I updated the eclipse when I run the application,I have an error,
MY LOGCAT
11-02 04:50:32.548: D/AndroidRuntime(2161): Shutting down VM 11-02 04:50:32.548: W/dalvikvm(2161): threadid=1: thread exiting with
uncaught exception (group=0x40a71930) 11-02 04:50:32.609:
E/AndroidRuntime(2161): FATAL EXCEPTION: main 11-02 04:50:32.609:
E/AndroidRuntime(2161): java.lang.RuntimeException: Unable to start
activity
ComponentInfo{com.vindypratama.tempatwisata/com.vindypratama.tempatwisata.MainMapActivity}:
android.view.InflateException: Binary XML file line #7: Error
inflating class fragment 11-02 04:50:32.609: E/AndroidRuntime(2161):
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
android.app.ActivityThread.access$600(ActivityThread.java:141) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
android.os.Handler.dispatchMessage(Handler.java:99) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
android.os.Looper.loop(Looper.java:137) 11-02 04:50:32.609:
E/AndroidRuntime(2161): at
android.app.ActivityThread.main(ActivityThread.java:5041) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
java.lang.reflect.Method.invokeNative(Native Method) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
java.lang.reflect.Method.invoke(Method.java:511) 11-02 04:50:32.609:
E/AndroidRuntime(2161): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
dalvik.system.NativeStart.main(Native Method) 11-02 04:50:32.609:
E/AndroidRuntime(2161): Caused by: android.view.InflateException:
Binary XML file line #7: Error inflating class fragment 11-02
04:50:32.609: E/AndroidRuntime(2161): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
android.view.LayoutInflater.inflate(LayoutInflater.java:489) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
android.view.LayoutInflater.inflate(LayoutInflater.java:396) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
android.view.LayoutInflater.inflate(LayoutInflater.java:352) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
android.app.Activity.setContentView(Activity.java:1881) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
com.vindypratama.tempatwisata.MainMapActivity.onCreate(MainMapActivity.java:25)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
android.app.Activity.performCreate(Activity.java:5104) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
11-02 04:50:32.609: E/AndroidRuntime(2161): ... 11 more 11-02
04:50:32.609: E/AndroidRuntime(2161): Caused by:
java.lang.IllegalStateException: The meta-data tag in your app's
AndroidManifest.xml does not have the right value. Expected 4030500
but found 0. You must have the following declaration within the
element: 11-02
04:50:32.609: E/AndroidRuntime(2161): at
com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown
Source) 11-02 04:50:32.609: E/AndroidRuntime(2161): at
com.google.android.gms.maps.internal.q.v(Unknown Source) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
com.google.android.gms.maps.internal.q.u(Unknown Source) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
com.google.android.gms.dynamic.a.a(Unknown Source) 11-02 04:50:32.609:
E/AndroidRuntime(2161): at
com.google.android.gms.dynamic.a.onInflate(Unknown Source) 11-02
04:50:32.609: E/AndroidRuntime(2161): at
com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown
Source) 11-02 04:50:32.609: E/AndroidRuntime(2161): at
android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
11-02 04:50:32.609: E/AndroidRuntime(2161): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
11-02 04:50:32.609: E/AndroidRuntime(2161): ... 21 more 11-02
04:50:45.858: I/Process(2161): Sending signal. PID: 2161 SIG: 9
My activity.java
package org.lucasr.twowayview;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.Menu;
public class MainMapActivity extends FragmentActivity
{
private GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_map);
setupMapIfNeeded();
}
private void setupMapIfNeeded()
{
if(map == null)
{
FragmentManager fragmentManager = getSupportFragmentManager();
SupportMapFragment supportMapFragment = (SupportMapFragment) fragmentManager.findFragmentById(R.id.maps);
map = supportMapFragment.getMap();
if(map != null)
{
setupMap();
}
}
}
private void setupMap()
{
map.setMyLocationEnabled(true);
moveToMyLocation();
}
private void moveToMyLocation()
{
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
location = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria, false));
if ( location != null)
{
map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 13));
}
}
#Override public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_map, menu);
return true;
}
protected void onResume()
{
super.onResume();
int resCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if( resCode != ConnectionResult.SUCCESS)
{
GooglePlayServicesUtil.getErrorDialog(resCode, this, 1);
}
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vindypratama.tempatwisata"
android:versionCode="1"
android:versionName="1.0" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.vindypratama.tempatwisata.permission.MAPS_RECEIVE" />
<permission
android:name="com.vindypratama.tempatwisata.permission.MAPS_RECEIVE"
android:protectionLevel="signature" >
</permission><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/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDcosD0fQsQcYCEiDDkRxP6ZRACPf-svaw" />
<activity
android:name="com.vindypratama.tempatwisata.MainMapActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application><manifest>
</manifest>
xml file:
<fragment
android:id="#+id/maps"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
/>
Try to use Project -> Clean. That actually helped me.
EDIT: If that doesn't help, try to relaunch Eclipse after Clean.
you are using a custom class - twowayview. fix you build path. check if you have checked the added jars in your build path. clean the project. delete bin folder.clear/refresh the project. it will work
Related
I'm trying to pass a string between 2 classes in Android . The first class is "MainActivity" and the second one is "abc" .
Here's my MainActivity code :
package com.example.passstrings;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
public class MainActivity extends ActionBarActivity {
String pass;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pass = "abcabc";
Intent abc = new Intent(this , abc.class);
abc.putExtra("key", pass);
startActivity(abc);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
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_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
return rootView;
}
}
}
and here's my abc class code :
package com.example.passstrings;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class abc extends Activity{
TextView tv1;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1=(TextView) findViewById(R.id.textView1);
Intent intent = getIntent();
String pass= intent.getExtras().getString("key");
if(pass!= null){
tv1.setText(pass);
}
}
}
Here's my fragment_main.xml code :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.passstrings.MainActivity$PlaceholderFragment" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView2"
android:layout_marginLeft="69dp"
android:layout_marginTop="72dp"
android:layout_toRightOf="#+id/textView2"
android:text="TextView" />
</RelativeLayout>
and here's my LogCat :
04-04 05:34:38.545: I/dalvikvm(734): Could not find method android.content.pm.PackageManager.getActivityLogo, referenced from method android.support.v7.internal.widget.ActionBarView.<init>
04-04 05:34:38.545: W/dalvikvm(734): VFY: unable to resolve virtual method 320: Landroid/content/pm/PackageManager;.getActivityLogo (Landroid/content/ComponentName;)Landroid/graphics/drawable/Drawable;
04-04 05:34:38.545: D/dalvikvm(734): VFY: replacing opcode 0x6e at 0x008b
04-04 05:34:38.545: I/dalvikvm(734): Could not find method android.content.pm.ApplicationInfo.loadLogo, referenced from method android.support.v7.internal.widget.ActionBarView.<init>
04-04 05:34:38.545: W/dalvikvm(734): VFY: unable to resolve virtual method 316: Landroid/content/pm/ApplicationInfo;.loadLogo (Landroid/content/pm/PackageManager;)Landroid/graphics/drawable/Drawable;
04-04 05:34:38.545: D/dalvikvm(734): VFY: replacing opcode 0x6e at 0x0099
04-04 05:34:38.555: D/dalvikvm(734): VFY: dead code 0x008e-0092 in Landroid/support/v7/internal/widget/ActionBarView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;)V
04-04 05:34:38.555: D/dalvikvm(734): VFY: dead code 0x009c-00a0 in Landroid/support/v7/internal/widget/ActionBarView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;)V
04-04 05:34:38.675: D/AndroidRuntime(734): Shutting down VM
04-04 05:34:38.675: W/dalvikvm(734): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-04 05:34:38.685: E/AndroidRuntime(734): FATAL EXCEPTION: main
04-04 05:34:38.685: E/AndroidRuntime(734): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.passstrings/com.example.passstrings.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.passstrings/com.example.passstrings.abc}; have you declared this activity in your AndroidManifest.xml?
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.os.Handler.dispatchMessage(Handler.java:99)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.os.Looper.loop(Looper.java:123)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-04 05:34:38.685: E/AndroidRuntime(734): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 05:34:38.685: E/AndroidRuntime(734): at java.lang.reflect.Method.invoke(Method.java:521)
04-04 05:34:38.685: E/AndroidRuntime(734): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-04 05:34:38.685: E/AndroidRuntime(734): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-04 05:34:38.685: E/AndroidRuntime(734): at dalvik.system.NativeStart.main(Native Method)
04-04 05:34:38.685: E/AndroidRuntime(734): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.passstrings/com.example.passstrings.abc}; have you declared this activity in your AndroidManifest.xml?
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.Activity.startActivityForResult(Activity.java:2817)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.Activity.startActivity(Activity.java:2923)
04-04 05:34:38.685: E/AndroidRuntime(734): at com.example.passstrings.MainActivity.onCreate(MainActivity.java:25)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-04 05:34:38.685: E/AndroidRuntime(734): ... 11 more
and here's my manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.passstrings"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.passstrings.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
If I remove "startActivity(abc);" the application doesn't crash, also if use try&catch the application doesn't crash but the same time it doesn't perform the action . So what could be the reason ? and thanks in advance
My LogCat after adding the activity to manifest :
04-04 05:47:16.555: I/dalvikvm(883): Could not find method android.content.pm.PackageManager.getActivityLogo, referenced from method android.support.v7.internal.widget.ActionBarView.<init>
04-04 05:47:16.555: W/dalvikvm(883): VFY: unable to resolve virtual method 320: Landroid/content/pm/PackageManager;.getActivityLogo (Landroid/content/ComponentName;)Landroid/graphics/drawable/Drawable;
04-04 05:47:16.555: D/dalvikvm(883): VFY: replacing opcode 0x6e at 0x008b
04-04 05:47:16.555: I/dalvikvm(883): Could not find method android.content.pm.ApplicationInfo.loadLogo, referenced from method android.support.v7.internal.widget.ActionBarView.<init>
04-04 05:47:16.565: W/dalvikvm(883): VFY: unable to resolve virtual method 316: Landroid/content/pm/ApplicationInfo;.loadLogo (Landroid/content/pm/PackageManager;)Landroid/graphics/drawable/Drawable;
04-04 05:47:16.565: D/dalvikvm(883): VFY: replacing opcode 0x6e at 0x0099
04-04 05:47:16.565: D/dalvikvm(883): VFY: dead code 0x008e-0092 in Landroid/support/v7/internal/widget/ActionBarView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;)V
04-04 05:47:16.565: D/dalvikvm(883): VFY: dead code 0x009c-00a0 in Landroid/support/v7/internal/widget/ActionBarView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;)V
04-04 05:47:16.775: D/AndroidRuntime(883): Shutting down VM
04-04 05:47:16.775: W/dalvikvm(883): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-04 05:47:16.786: E/AndroidRuntime(883): FATAL EXCEPTION: main
04-04 05:47:16.786: E/AndroidRuntime(883): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.passstrings/com.example.passstrings.abc}: java.lang.NullPointerException
04-04 05:47:16.786: E/AndroidRuntime(883): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-04 05:47:16.786: E/AndroidRuntime(883): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-04 05:47:16.786: E/AndroidRuntime(883): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-04 05:47:16.786: E/AndroidRuntime(883): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-04 05:47:16.786: E/AndroidRuntime(883): at android.os.Handler.dispatchMessage(Handler.java:99)
04-04 05:47:16.786: E/AndroidRuntime(883): at android.os.Looper.loop(Looper.java:123)
04-04 05:47:16.786: E/AndroidRuntime(883): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-04 05:47:16.786: E/AndroidRuntime(883): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 05:47:16.786: E/AndroidRuntime(883): at java.lang.reflect.Method.invoke(Method.java:521)
04-04 05:47:16.786: E/AndroidRuntime(883): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-04 05:47:16.786: E/AndroidRuntime(883): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-04 05:47:16.786: E/AndroidRuntime(883): at dalvik.system.NativeStart.main(Native Method)
04-04 05:47:16.786: E/AndroidRuntime(883): Caused by: java.lang.NullPointerException
04-04 05:47:16.786: E/AndroidRuntime(883): at com.example.passstrings.abc.onCreate(abc.java:20)
04-04 05:47:16.786: E/AndroidRuntime(883): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-04 05:47:16.786: E/AndroidRuntime(883): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-04 05:47:16.786: E/AndroidRuntime(883): ... 11 more
and my Manifest after the update :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.passstrings"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.passstrings.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.passstrings.abc" />
</application>
</manifest>
You need to add your second Activity to your Androidmanifest.xml file.
<activity android:name="com.example.passstrings.abc" />
have you declared this activity in your AndroidManifest.xml?
04-04 05:34:38.685: E/AndroidRuntime(734): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
it clearly say's that you have not declared your abc activity in manifest file. have you declared this activity in your AndroidManifest.xml?
so just decalre your abc activity in manifest file.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.passstrings.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".abc"
</activity>
</application>
add this line
<activity
android:name=".abc"
</activity>
and also change this in your abc.java
setContentView(R.layout.activity_main);
you have reference of activity_main only you have to set abc.XML or whatever your XML filename for abc. So change it with
setContentView(R.layout.abc);
Edit
public class abc extends Activity{
TextView tv1;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
tv1=(TextView) findViewById(R.id.textView1);
Intent intent = getIntent();
String pass= intent.getExtras().getString("key");
if(pass!= null){
tv1.setText(pass);
}
}
It is simply ActivityNotFoundException which mean you forgot to declare abc activity in your AndroidManifest.xml file.
Just add following line in your manifest.xml in application tag.
<activity android:name="com.example.passstrings.abc" />
For your new NullPointerException here is the solution
You have defined following .xml in your Activity file activity_main while you have declare TextViews in fragment_main.xml, that's why it is giving NullPointerException.
I suggest you to change the xml from following line
setContentView(R.layout.activity_main);
to
setContentView(R.layout.fragment_main.xml);
I posted my code below my application shows no errors int eh debug menu, when I run it logcat shows one error I posted it below. When I try to run the app on my phone it closes and stops responding and im not sure why. I was following an online tutorial and did it exactly how it said. Please help.
10-07 14:50:02.901: I/Process(11653): Sending signal. PID: 11653 SIG: 9
10-07 14:50:06.124: W/dalvikvm(11801): VFY: unable to resolve static field 1346 (MapAttrs) in Lcom/google/android/gms/R$styleable;
10-07 14:50:06.124: D/dalvikvm(11801): VFY: replacing opcode 0x62 at 0x000e
10-07 14:50:06.134: D/AndroidRuntime(11801): Shutting down VM
10-07 14:50:06.134: W/dalvikvm(11801): threadid=1: thread exiting with uncaught exception (group=0x4129bac8)
10-07 14:50:06.134: E/AndroidRuntime(11801): FATAL EXCEPTION: main
10-07 14:50:06.134: E/AndroidRuntime(11801): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
10-07 14:50:06.134: E/AndroidRuntime(11801): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
10-07 14:50:06.134: E/AndroidRuntime(11801): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:284)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:682)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
10-07 14:50:06.134: E/AndroidRuntime(11801): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:327)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.app.Activity.setContentView(Activity.java:1928)
10-07 14:50:06.134: E/AndroidRuntime(11801): at com.example.gloc.MainActivity.onCreate(MainActivity.java:30)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.app.Activity.performCreate(Activity.java:5250)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2297)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.app.ActivityThread.access$700(ActivityThread.java:152)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.os.Handler.dispatchMessage(Handler.java:99)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.os.Looper.loop(Looper.java:137)
10-07 14:50:06.134: E/AndroidRuntime(11801): at android.app.ActivityThread.main(ActivityThread.java:5328)
10-07 14:50:06.134: E/AndroidRuntime(11801): at java.lang.reflect.Method.invokeNative(Native Method)
10-07 14:50:06.134: E/AndroidRuntime(11801): at java.lang.reflect.Method.invoke(Method.java:511)
10-07 14:50:06.134: E/AndroidRuntime(11801): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
10-07 14:50:06.134: E/AndroidRuntime(11801): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
10-07 14:50:06.134: E/AndroidRuntime(11801): at dalvik.system.NativeStart.main(Native Method)
MainActivity.java
package com.example.gloc;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.TextView;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
public class MainActivity extends FragmentActivity implements LocationListener {
GoogleMap googleMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Getting Google Play availability status
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
// Showing status
if(status!=ConnectionResult.SUCCESS){ // Google Play Services are not available
int requestCode = 10;
//Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
//dialog.show();
}else { // Google Play Services are available
// Getting reference to the SupportMapFragment of activity_main.xml
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
// Getting GoogleMap object from the fragment
googleMap = fm.getMap();
// Enabling MyLocation Layer of Google Map
googleMap.setMyLocationEnabled(true);
// Getting LocationManager object from System Service LOCATION_SERVICE
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
// Creating a criteria object to retrieve provider
Criteria criteria = new Criteria();
// Getting the name of the best provider
String provider = locationManager.getBestProvider(criteria, true);
// Getting Current Location
Location location = locationManager.getLastKnownLocation(provider);
if(location!=null){
onLocationChanged(location);
}
locationManager.requestLocationUpdates(provider, 20000, 0, this);
}
}
#Override
public void onLocationChanged(Location location) {
TextView tvLocation = (TextView) findViewById(R.id.tv_location);
// Getting latitude of the current location
double latitude = location.getLatitude();
// Getting longitude of the current location
double longitude = location.getLongitude();
// Creating a LatLng object for the current location
LatLng latLng = new LatLng(latitude, longitude);
// Showing the current location in Google Map
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
// Zoom in the Google Map
googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
// Setting latitude and longitude in the TextView tv_location
tvLocation.setText("Latitude:" + latitude + ", Longitude:"+ longitude );
}
#Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
#Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TextView
android:id="#+id/tv_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/tv_location"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gloc"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="18" />
<permission
android:name="in.wptrafficanalyzer.locationingooglemapv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="in.wptrafficanalyzer.locationingooglemapv2.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<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_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<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/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="IEARASEDTHSITOHIDEIT"/>
<activity
android:name="com.example.gloc.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
You can't change the map options in onCreate, as it has not yet been instantiated. Try doing all of the stuff in OnLocationChanged to your GoogleMap object in onResume() instead of onCreate().
main.java
package com.learnactivities;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Main extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(Main.this, Second.class));
}
});
}
}
activity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".Main" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button1" />
</RelativeLayout>
Second.java
package com.learnactivities;
import android.app.Activity;
import android.os.Bundle;
public class Second extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
}
}
second.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".Second" >
<TextView
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="16dp"
android:layout_marginTop="15dp"
android:text="#string/nd" />
</RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.learnactivities"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.learnactivities.Main"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".second" />
</application>
</manifest>
I m getting following errors. I can see that error caused by java.lang.NullPointerException. I did my best searching here and there but could not get to the solution.Plz, anyone help me sort this problem out?
08-25 19:08:44.442: D/AndroidRuntime(276): Shutting down VM
08-25 19:08:44.442: W/dalvikvm(276): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
08-25 19:08:44.472: E/AndroidRuntime(276): FATAL EXCEPTION: main
08-25 19:08:44.472: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.learnactivities/com.learnactivities.Main}: java.lang.NullPointerException
08-25 19:08:44.472: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
08-25 19:08:44.472: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-25 19:08:44.472: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-25 19:08:44.472: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-25 19:08:44.472: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
08-25 19:08:44.472: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
08-25 19:08:44.472: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-25 19:08:44.472: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
08-25 19:08:44.472: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
08-25 19:08:44.472: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-25 19:08:44.472: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-25 19:08:44.472: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
08-25 19:08:44.472: E/AndroidRuntime(276): Caused by: java.lang.NullPointerException
08-25 19:08:44.472: E/AndroidRuntime(276): at com.learnactivities.Main.onCreate(Main.java:19)
08-25 19:08:44.472: E/AndroidRuntime(276): at `android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)`
`08-25 19:08:44.472: E/AndroidRuntime(276): at` `android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)`
08-25 19:08:44.472: E/AndroidRuntime(276): ... 11 more
R.id.button1 is declared inside second.xml, but you are looking for it inside activity.xml. So in Main, when you do
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener()
findViewById is returning null
Try this in your main class..
TextView b = (TextView ) findViewById(R.id.textView1);
b.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(Main.this, Second.class));
}
});
and also in manifest change like below line
<activity android:name=".Second" />
I try to implement an application based on rscm (middleware). When I try to run on emulator, I get the errors listed below:
Error :03-27 16:58:20.490: E/Trace(1508): error opening trace file: No
such file or directory (2)
03-27 21:53:21.610: D/AndroidRuntime(3803): Shutting down VM 03-27
21:53:21.610: W/dalvikvm(3803): threadid=1: thread exiting with
uncaught exception (group=0x40a71930) 03-27 21:53:21.760:
E/AndroidRuntime(3803): FATAL EXCEPTION: main 03-27 21:53:21.760:
E/AndroidRuntime(3803): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{com.example.context_application/com.example.context_application.MyContextAwareActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.example.context_application.MyContextAwareActivity" on path:
/data/app/com.example.context_application-2.apk 03-27 21:53:21.760:
E/AndroidRuntime(3803): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
03-27 21:53:21.760: E/AndroidRuntime(3803): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-27 21:53:21.760: E/AndroidRuntime(3803): at
android.app.ActivityThread.access$600(ActivityThread.java:141) 03-27
21:53:21.760: E/AndroidRuntime(3803): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-27 21:53:21.760: E/AndroidRuntime(3803): at
android.os.Handler.dispatchMessage(Handler.java:99) 03-27
21:53:21.760: E/AndroidRuntime(3803): at
android.os.Looper.loop(Looper.java:137) 03-27 21:53:21.760:
E/AndroidRuntime(3803): at
android.app.ActivityThread.main(ActivityThread.java:5041) 03-27
21:53:21.760: E/AndroidRuntime(3803): at
java.lang.reflect.Method.invokeNative(Native Method) 03-27
21:53:21.760: E/AndroidRuntime(3803): at
java.lang.reflect.Method.invoke(Method.java:511) 03-27 21:53:21.760:
E/AndroidRuntime(3803): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-27 21:53:21.760: E/AndroidRuntime(3803): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 03-27
21:53:21.760: E/AndroidRuntime(3803): at
dalvik.system.NativeStart.main(Native Method) 03-27 21:53:21.760:
E/AndroidRuntime(3803): Caused by: java.lang.ClassNotFoundException:
Didn't find class
"com.example.context_application.MyContextAwareActivity" on path:
/data/app/com.example.context_application-2.apk 03-27 21:53:21.760:
E/AndroidRuntime(3803): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
03-27 21:53:21.760: E/AndroidRuntime(3803): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501) 03-27
21:53:21.760: E/AndroidRuntime(3803): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461) 03-27
21:53:21.760: E/AndroidRuntime(3803): at
android.app.Instrumentation.newActivity(Instrumentation.java:1054)
03-27 21:53:21.760: E/AndroidRuntime(3803): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
03-27 21:53:21.760: E/AndroidRuntime(3803): ... 11 more
Can anyone help?
package com.example.context;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import org.aspectsense.rscm.ContextValue;
import org.aspectsense.rscm.context.client.ContextListenerActivity;
import org.json.JSONException;
import java.util.Date;
public class MyContextAwareActivity extends ContextListenerActivity
{
#Override public String[] getRequestedScopes()
{
return new String[] { "battery.level" };
}
private TextView messageTextView;
#Override protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
messageTextView = new TextView(this);
setContentView(messageTextView);
appendMessage("Activity created");
}
private void appendMessage(final String message)
{
final String currentMessage = messageTextView.getText().toString();
messageTextView.setText(currentMessage + "\n" + message);
}
#Override public void onContextValueChanged(ContextValue contextValue)
{
try
{
appendMessage(new Date() + ": The battery level is " + contextValue.getValueAsInteger() + "%");
}
catch (JSONException jsone)
{
Toast.makeText(this, "Error while displaying context event: " + contextValue, Toast.LENGTH_SHORT).show();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.context"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.context.MyContextAwareActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
You are telling it to write to external storage. Have you set up an SD card in eclipse?
Do any of these answers help? error opening trace file: No such file or directory (2)
I'm trying to Insert an event to Calendar Using an Intent with the following code:
package come.jobfinder.dev;
import java.util.Calendar;
import org.junit.Test;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Intent;
import android.net.Uri;
import android.provider.CalendarContract;
import android.provider.CalendarContract.Events;
public class CalendarWrapper extends Activity {
public void syncDataWithCalendar(String workPlace , Calendar date){
//TODO should be a field that user should fill - intreviewLength
int intreviewLength = 60;// set it default to be an hour , will be a field user should fill
//TODO should be a field that will be sent - position
String position = "Product Manager";
//TODO should be a field that will be sent - location
String location = "Tel Aviv";
//TODO need to check where to take this argument from
long calID = 3;
Calendar beginTime = Calendar.getInstance();
beginTime.set(date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH), date.get(Calendar.HOUR), date.get(Calendar.MINUTE));
Calendar endTime = Calendar.getInstance();
endTime.set(date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH), date.get(Calendar.HOUR), date.get(Calendar.MINUTE)+intreviewLength);
Intent intent = new Intent(Intent.ACTION_INSERT)
.setData(Events.CONTENT_URI)
.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis())
.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis())
.putExtra(Events.TITLE, "Job Interview with "+workPlace)
.putExtra(Events.DESCRIPTION, "Job interview with "+workPlace+" for the position"+position)
.putExtra(Events.EVENT_LOCATION, location)
.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY)
.putExtra(Intent.EXTRA_EMAIL, "rowan#example.com,trevor#example.com");
startActivity(intent);
//return intent;
// get the event ID that is the last element in the Uri
}
}
and get the following errors:
11-02 21:22:07.580: E/AndroidRuntime(15871): FATAL EXCEPTION: main
11-02 21:22:07.580: E/AndroidRuntime(15871): java.lang.NullPointerException
11-02 21:22:07.580: E/AndroidRuntime(15871): at android.app.Activity.startActivityForResult(Activity.java:3195)
11-02 21:22:07.580: E/AndroidRuntime(15871): at android.app.Activity.startActivity(Activity.java:3302)
11-02 21:22:07.580: E/AndroidRuntime(15871): at come.jobfinder.dev.CalendarWrapper.syncDataWithCalendar(CalendarWrapper.java:45)
11-02 21:22:07.580: E/AndroidRuntime(15871): at come.jobfinder.dev.UpdateWorkPlace.onClick(UpdateWorkPlace.java:90)
11-02 21:22:07.580: E/AndroidRuntime(15871): at android.view.View.performClick(View.java:3627)
11-02 21:22:07.580: E/AndroidRuntime(15871): at android.view.View$PerformClick.run(View.java:14329)
11-02 21:22:07.580: E/AndroidRuntime(15871): at android.os.Handler.handleCallback(Handler.java:605)
11-02 21:22:07.580: E/AndroidRuntime(15871): at android.os.Handler.dispatchMessage(Handler.java:92)
11-02 21:22:07.580: E/AndroidRuntime(15871): at android.os.Looper.loop(Looper.java:137)
11-02 21:22:07.580: E/AndroidRuntime(15871): at android.app.ActivityThread.main(ActivityThread.java:4511)
11-02 21:22:07.580: E/AndroidRuntime(15871): at java.lang.reflect.Method.invokeNative(Native Method)
11-02 21:22:07.580: E/AndroidRuntime(15871): at java.lang.reflect.Method.invoke(Method.java:511)
11-02 21:22:07.580: E/AndroidRuntime(15871): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
11-02 21:22:07.580: E/AndroidRuntime(15871): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
11-02 21:22:07.580: E/AndroidRuntime(15871): at dalvik.system.NativeStart.main(Native Method)
Thanks from a head
Nir
It's difficult to tell what's going ong. You're getting a null pointer exception in the trace, which of the source statements is failing?