My logcat error and code is given below:
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Logcat:
08-15 11:42:43.735: D/AndroidRuntime(1864): Shutting down VM
08-15 11:42:43.735: W/dalvikvm(1864): threadid=1: thread exiting with uncaught exception (group=0xb1d54ce8)
08-15 11:42:43.755: E/AndroidRuntime(1864): FATAL EXCEPTION: main
08-15 11:42:43.755: E/AndroidRuntime(1864): Process: com.example.helloworld, PID: 1864
08-15 11:42:43.755: E/AndroidRuntime(1864): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloworld/com.example.helloworld.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
08-15 11:42:43.755: E/AndroidRuntime(1864): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
08-15 11:42:43.755: E/AndroidRuntime(1864): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
08-15 11:42:43.755: E/AndroidRuntime(1864): at android.app.ActivityThread.access$800(ActivityThread.java:138)
08-15 11:42:43.755: E/AndroidRuntime(1864): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
08-15 11:42:43.755: E/AndroidRuntime(1864): at android.os.Handler.dispatchMessage(Handler.java:102)
08-15 11:42:43.755: E/AndroidRuntime(1864): at android.os.Looper.loop(Looper.java:136)
08-15 11:42:43.755: E/AndroidRuntime(1864): at android.app.ActivityThread.main(ActivityThread.java:5026)
08-15 11:42:43.755: E/AndroidRuntime(1864): at java.lang.reflect.Method.invokeNative(Native Method)
08-15 11:42:43.755: E/AndroidRuntime(1864): at java.lang.reflect.Method.invoke(Method.java:515)
08-15 11:42:43.755: E/AndroidRuntime(1864): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
08-15 11:42:43.755: E/AndroidRuntime(1864): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
08-15 11:42:43.755: E/AndroidRuntime(1864): at dalvik.system.NativeStart.main(Native Method)
08-15 11:42:43.755: E/AndroidRuntime(1864): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
08-15 11:42:43.755: E/AndroidRuntime(1864): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
08-15 11:42:43.755: E/AndroidRuntime(1864): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
08-15 11:42:43.755: E/AndroidRuntime(1864): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
08-15 11:42:43.755: E/AndroidRuntime(1864): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
08-15 11:42:43.755: E/AndroidRuntime(1864): at android.app.Activity.setContentView(Activity.java:1930)
08-15 11:42:43.755: E/AndroidRuntime(1864): at com.example.helloworld.MainActivity.onCreate(MainActivity.java:14)
08-15 11:42:43.755: E/AndroidRuntime(1864): at android.app.Activity.performCreate(Activity.java:5242)
08-15 11:42:43.755: E/AndroidRuntime(1864): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-15 11:42:43.755: E/AndroidRuntime(1864): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
08-15 11:42:43.755: E/AndroidRuntime(1864): ... 11 more
In your manifest .xml change target-sdk to 19.!
I think you are targeting the wrong device. If memory serves me right, it sounds like you might be targeting Android Wear.
If you are developing a mobile application, change your target sdk to API 19
Related
I'm programming Android 2.3 (API 10) application.
I've managed to create a custom view to my Notification object with ImageView and TextView.
I want to add to my Notification a ToggleButton (Kind of like the toggle button exists in the phone call options in the notification when you're in a middle of a phone call with "Speaker" and "Mute" Toggle buttons).
Every time i'm trying to do so - my application's crash with the following error:
08-15 00:15:55.370: E/AndroidRuntime(17000): FATAL EXCEPTION: main
08-15 00:15:55.370: E/AndroidRuntime(17000): android.app.RemoteServiceException: Bad notification posted from package com.coapps.pico: Couldn't expand RemoteViews for: StatusBarNotification(package=com.coapps.pico id=0 tag=null notification=Notification(vibrate=null,sound=null,defaults=0x0,flags=0x0))
08-15 00:15:55.370: E/AndroidRuntime(17000): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1048)
08-15 00:15:55.370: E/AndroidRuntime(17000): at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 00:15:55.370: E/AndroidRuntime(17000): at android.os.Looper.loop(Looper.java:130)
08-15 00:15:55.370: E/AndroidRuntime(17000): at android.app.ActivityThread.main(ActivityThread.java:3691)
08-15 00:15:55.370: E/AndroidRuntime(17000): at java.lang.reflect.Method.invokeNative(Native Method)
08-15 00:15:55.370: E/AndroidRuntime(17000): at java.lang.reflect.Method.invoke(Method.java:507)
08-15 00:15:55.370: E/AndroidRuntime(17000): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
08-15 00:15:55.370: E/AndroidRuntime(17000): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
08-15 00:15:55.370: E/AndroidRuntime(17000): at dalvik.system.NativeStart.main(Native Method)
Any idea how can i make it work ?
Usually bad notification error occurs during notification building process;
when you try to include views which are not ought to be used in notification(Here is the reference to the video where it is mentioned "https://www.youtube.com/watch?v=ToUR9i4Smfw").
Conclusion:
Remove ToggleButton from custom layout;
try to use ImageButton instead.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Trying to Integrate facebook sdk to android app but my app is not starting. There are the logs. How can I fix this runtime exception?
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView pic = (ImageView) findViewById(R.id.imageView1);
Button btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(this);
}
08-15 11:48:21.712: E/AndroidRuntime(564): FATAL EXCEPTION: main
08-15 11:48:21.712: E/AndroidRuntime(564): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sri.z4globalsoft/com.sri.z4globalsoft.MainActivity}: java.lang.NullPointerException
08-15 11:48:21.712: E/AndroidRuntime(564): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
08-15 11:48:21.712: E/AndroidRuntime(564): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
08-15 11:48:21.712: E/AndroidRuntime(564): at android.app.ActivityThread.access$600(ActivityThread.java:122)
08-15 11:48:21.712: E/AndroidRuntime(564): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
08-15 11:48:21.712: E/AndroidRuntime(564): at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 11:48:21.712: E/AndroidRuntime(564): at android.os.Looper.loop(Looper.java:137)
08-15 11:48:21.712: E/AndroidRuntime(564): at android.app.ActivityThread.main(ActivityThread.java:4340)
08-15 11:48:21.712: E/AndroidRuntime(564): at java.lang.reflect.Method.invokeNative(Native Method)
08-15 11:48:21.712: E/AndroidRuntime(564): at java.lang.reflect.Method.invoke(Method.java:511)
08-15 11:48:21.712: E/AndroidRuntime(564): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-15 11:48:21.712: E/AndroidRuntime(564): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-15 11:48:21.712: E/AndroidRuntime(564): at dalvik.system.NativeStart.main(Native Method)
08-15 11:48:21.712: E/AndroidRuntime(564): Caused by: java.lang.NullPointerException
08-15 11:48:21.712: E/AndroidRuntime(564): at android.content.ContextWrapper.getResources(ContextWrapper.java:81)
08-15 11:48:21.712: E/AndroidRuntime(564): at com.sri.z4globalsoft.MainActivity.<init>(MainActivity.java:23)
08-15 11:48:21.712: E/AndroidRuntime(564): at java.lang.Class.newInstanceImpl(Native Method)
08-15 11:48:21.712: E/AndroidRuntime(564): at java.lang.Class.newInstance(Class.java:1319)
08-15 11:48:21.712: E/AndroidRuntime(564): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-15 11:48:21.712: E/AndroidRuntime(564): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
08-15 11:48:21.712: E/AndroidRuntime(564): ... 11 more
Tried by changing the code ap per your answers given below then also having problem
08-15 12:25:00.800: E/AndroidRuntime(712): FATAL EXCEPTION: main
08-15 12:25:00.800: E/AndroidRuntime(712): java.lang.NoClassDefFoundError: com.facebook.android.Facebook
08-15 12:25:00.800: E/AndroidRuntime(712): at com.sri.z4globalsoft.MainActivity.<init>(MainActivity.java:25)
08-15 12:25:00.800: E/AndroidRuntime(712): at java.lang.Class.newInstanceImpl(Native Method)
08-15 12:25:00.800: E/AndroidRuntime(712): at java.lang.Class.newInstance(Class.java:1319)
08-15 12:25:00.800: E/AndroidRuntime(712): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-15 12:25:00.800: E/AndroidRuntime(712): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
08-15 12:25:00.800: E/AndroidRuntime(712): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
08-15 12:25:00.800: E/AndroidRuntime(712): at android.app.ActivityThread.access$600(ActivityThread.java:122)
08-15 12:25:00.800: E/AndroidRuntime(712): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
08-15 12:25:00.800: E/AndroidRuntime(712): at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 12:25:00.800: E/AndroidRuntime(712): at android.os.Looper.loop(Looper.java:137)
08-15 12:25:00.800: E/AndroidRuntime(712): at android.app.ActivityThread.main(ActivityThread.java:4340)
08-15 12:25:00.800: E/AndroidRuntime(712): at java.lang.reflect.Method.invokeNative(Native Method)
08-15 12:25:00.800: E/AndroidRuntime(712): at java.lang.reflect.Method.invoke(Method.java:511)
08-15 12:25:00.800: E/AndroidRuntime(712): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-15 12:25:00.800: E/AndroidRuntime(712): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-15 12:25:00.800: E/AndroidRuntime(712): at dalvik.system.NativeStart.main(Native Method)
It sound like you might be trying to use getResources() before they are technically ready.
If you have this:
String APP_ID = getResources().getString(R.string.APP_ID);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
}
Do this instead:
String APP_ID;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
APP_ID = getResources().getString(R.string.APP_ID);
...
}
08-15 11:48:21.712: E/AndroidRuntime(564): Caused by: java.lang.NullPointerException
08-15 11:48:21.712: E/AndroidRuntime(564): at android.content.ContextWrapper.getResources(ContextWrapper.java:81)
08-15 11:48:21.712: E/AndroidRuntime(564): at com.sri.z4globalsoft.MainActivity.<init>(MainActivity.java:23)
You're trying to initialize a member variable where the initialization is using this as Context. In this case it's the getResources() call. You can only use the Activity as a Context in onCreate() or later in the activity lifecycle.
Specifically (from question comments), change this:
String APP_ID = getResources().getString(R.string.APP_ID);
to something like:
String APP_ID;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
APP_ID = getResources().getString(R.string.APP_ID);
//...
Integrating facebook sdk with android app.before integrating app working fine but once working with facebook app stopped unexpectedly here i am placing the code.suggest me how to fix this
public class MainActivity extends Activity implements OnClickListener {
Button btnTOLogin, btnTOPost, logOut;
String APP_ID;
Facebook fb;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
APP_ID = "308180782571605";
fb = new Facebook(APP_ID);
try {
btnTOLogin = (Button) findViewById(R.id.button1);
btnTOPost = (Button) findViewById(R.id.button2);
logOut = (Button) findViewById(R.id.button3);
btnTOLogin.setOnClickListener(this);
btnTOPost.setOnClickListener(this);
logOut.setOnClickListener(this);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
here logs
08-15 22:08:52.531: E/AndroidRuntime(2151): FATAL EXCEPTION: main
08-15 22:08:52.531: E/AndroidRuntime(2151): java.lang.NoClassDefFoundError: com.facebook.android.Facebook
08-15 22:08:52.531: E/AndroidRuntime(2151): at com.sri.z4globalsoft.MainActivity.onCreate(MainActivity.java:25)
08-15 22:08:52.531: E/AndroidRuntime(2151): at android.app.Activity.performCreate(Activity.java:4465)
08-15 22:08:52.531: E/AndroidRuntime(2151): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-15 22:08:52.531: E/AndroidRuntime(2151): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
08-15 22:08:52.531: E/AndroidRuntime(2151): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
08-15 22:08:52.531: E/AndroidRuntime(2151): at android.app.ActivityThread.access$600(ActivityThread.java:122)
08-15 22:08:52.531: E/AndroidRuntime(2151): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
08-15 22:08:52.531: E/AndroidRuntime(2151): at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 22:08:52.531: E/AndroidRuntime(2151): at android.os.Looper.loop(Looper.java:137)
08-15 22:08:52.531: E/AndroidRuntime(2151): at android.app.ActivityThread.main(ActivityThread.java:4340)
08-15 22:08:52.531: E/AndroidRuntime(2151): at java.lang.reflect.Method.invokeNative(Native Method)
08-15 22:08:52.531: E/AndroidRuntime(2151): at java.lang.reflect.Method.invoke(Method.java:511)
08-15 22:08:52.531: E/AndroidRuntime(2151): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-15 22:08:52.531: E/AndroidRuntime(2151): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-15 22:08:52.531: E/AndroidRuntime(2151): at dalvik.system.NativeStart.main(Native Method)
Go to Project -> Properties -> Java Build Path -> Order & Export and make sure facebook library is ticked.
clean the project..|
go to libs folder select facebookjar right click and select add to build path
(or) Java Build Path -> Order & Export and make sure facebook library is ticked.
some times it depends on order of libraries in order and export move up and down check it may come
I am just trying to launch camera from my android emulator and I am getting the above error
unfortunately camera has stopped android emulator and it stopped
My Android Version 4.0.3 and API 15
My Logs are below ,I have already gone through the other posts in stack overflow related to this but no luck
08-15 18:55:53.361: E/EmulatedCamera_QemuClient(38): queryFrame: Query failed: Unable to obtain video frame from the camera
08-15 18:55:53.361: E/EmulatedCamera_QemuDevice(38): inWorkerThread: Unable to get current video frame: Invalid argument
08-15 18:55:53.401: I/dalvikvm(472): Wrote stack traces to '/data/anr/traces.txt'
08-15 18:55:53.561: E/Camera(472): Error 100
08-15 18:55:53.561: E/CameraErrorCallback(472): Got camera error callback. error=100
08-15 18:55:53.571: D/AndroidRuntime(472): Shutting down VM
08-15 18:55:53.571: W/dalvikvm(472): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
08-15 18:55:53.591: E/AndroidRuntime(472): FATAL EXCEPTION: main
08-15 18:55:53.591: E/AndroidRuntime(472): java.lang.RuntimeException: Media server died.
08-15 18:55:53.591: E/AndroidRuntime(472): at com.android.camera.CameraErrorCallback.onError(CameraErrorCallback.java:31)
08-15 18:55:53.591: E/AndroidRuntime(472): at android.hardware.Camera$EventHandler.handleMessage(Camera.java:736)
08-15 18:55:53.591: E/AndroidRuntime(472): at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 18:55:53.591: E/AndroidRuntime(472): at android.os.Looper.loop(Looper.java:137)
08-15 18:55:53.591: E/AndroidRuntime(472): at android.app.ActivityThread.main(ActivityThread.java:4424)
08-15 18:55:53.591: E/AndroidRuntime(472): at java.lang.reflect.Method.invokeNative(Native Method)
08-15 18:55:53.591: E/AndroidRuntime(472): at java.lang.reflect.Method.invoke(Method.java:511)
08-15 18:55:53.591: E/AndroidRuntime(472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-15 18:55:53.591: E/AndroidRuntime(472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-15 18:55:53.591: E/AndroidRuntime(472): at dalvik.system.NativeStart.main(Native Method)
08-15 18:55:53.621: W/ActivityManager(92): Force finishing activity com.android.camera/.Camera
08-15 18:55:53.631: W/WindowManager(92): Failure taking screenshot for (180x300) to layer 21015
08-15 18:55:53.811: I/Process(92): Sending signal. PID: 472 SIG: 3
08-15 18:55:53.811: I/dalvikvm(472): threadid=3: reacting to signal 3
My problem is in starting new activities.
I have ListView, items of it are defined from string-array by this code:
listBanksUA = getResources().getStringArray(R.array.list_banks_ua);
setListAdapter(new ArrayAdapter<String(this,android.R.layout.simple_list_item_1,listBanksUA));
List is defined in layout as:
<ListView android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"/>
So, I'd like to start new activity after click on item of ListView. Sure, I have created new XML-layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#+id/listRegions"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"/>
</LinearLayout>
and Java-class for it: ListRegionsActivity.class.
In my first Activity I use the follow code to start new Activity:
#Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
startActivity(new Intent(MainActivity.this,ListRegionsActivity.class));
}
and after clicking in started application I'm getting an error, that my application has been closed with advice to try again. Sadness...
So, really I'll be glad for any help for me.
BTW: of course, I added new activity to manifest file.
UPD: my LogCAT with Error flag
08-15 13:46:45.458: ERROR/AndroidRuntime(516): Uncaught handler: thread main exiting due to uncaught exception
08-15 13:46:45.488: ERROR/AndroidRuntime(516): java.lang.RuntimeException: Unable to start activity ComponentInfo{ua.donetsk.jeston.android/ua.donetsk.jeston.android.ListRegionsActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at android.os.Looper.loop(Looper.java:123)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at android.app.ActivityThread.main(ActivityThread.java:4203)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at java.lang.reflect.Method.invokeNative(Native Method)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at java.lang.reflect.Method.invoke(Method.java:521)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at dalvik.system.NativeStart.main(Native Method)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at android.app.ListActivity.onContentChanged(ListActivity.java:236)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:316)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at android.app.Activity.setContentView(Activity.java:1620)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at ua.donetsk.jeston.android.ListRegionsActivity.onCreate(ListRegionsActivity.java:15)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
08-15 13:46:45.488: ERROR/AndroidRuntime(516): ... 11 more
UPD: the problem is solved. The reason was in incorrect mistake in opening avtivity - setContentView should be deleted.
Since you did not showed us the LogCat trace, I can do the guess.
Try this in the ListView click listener
MainActivity.this.startActivity(new Intent(MainActivity.this,ListRegionsActivity.class))
And dont forget to add the new activity in your manifest.
Check you're not importing android.R in your app instead of your.package.R