Emulator Problem, when running app with gestures

0 Shivam Arora · April 21, 2015
I launched the application, but emulator said "Unfortunately, Application has stopped working", I have increased my emulator's VM heap from 62 to 128 but still Its not running, what should I do? 

***(This is in context with this tutorial = Android App Development for Beginners - 22 - Running the Gesture App)***

Post a Reply

Replies

Oldest  Newest  Rating
0 Faruq Kazi · June 14, 2015
Hello guys,

I am trying to get Gesture response but no response at all

Java and xml are pasted as it is, anybody could help me out..??
==================================================Strings.Xml
<resources>
<string name="app_name">Gesture</string>

<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="buckys_text">Large Text</string>
</resources>
==========================================================MainActivity

<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/buckys_text"
android:id="@+id/buckysMessage"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>


=====================Java script
package com.example.kazi.gesture;

import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.view.MotionEvent;
import android.view.GestureDetector;
import android.support.v4.view.GestureDetectorCompat;

public class MainActivity extends Activity implements GestureDetector.OnGestureListener,
GestureDetector.OnDoubleTapListener {
private TextView buckysMessage;
private GestureDetectorCompat gestureDetector;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

buckysMessage=(TextView)findViewById(R.id.buckysMessage);
this.gestureDetector=new GestureDetectorCompat(this,this);
gestureDetector.setOnDoubleTapListener(this);


}
////////// gesture starts

@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
buckysMessage.setText("OnSingleTapConfirmed");
return true;
}

@Override
public boolean onDoubleTap(MotionEvent e) {
buckysMessage.setText("onDoubleTap");
return true;
}

@Override
public boolean onDoubleTapEvent(MotionEvent e) {
buckysMessage.setText("onDoubleTapEvent");
return true;
}

@Override
public boolean onDown(MotionEvent e) {
buckysMessage.setText("onDown");
return true;
}

@Override
public void onShowPress(MotionEvent e) {
buckysMessage.setText("onShowPress");
}

@Override
public boolean onSingleTapUp(MotionEvent e) {
buckysMessage.setText("onSingleTapUp");
return true;
}

@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
buckysMessage.setText("onScroll");
return true;
}

@Override
public void onLongPress(MotionEvent e) {
buckysMessage.setText("onLongPress");
}

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
buckysMessage.setText("onFling");
return true;
}
// Gesture////////////////
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.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();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}
0 Reuven Karasik · June 14, 2015
Look for errors in your app. For me, what did the trick was a small error on the manifest file about not public activity, so I went to the 'class MainActivity extends ActionBarActivity' line and added a simple 'public' before the class ('public class MainActivity extends ActionBarActivity'). It solved all my problems :)
0 Thulasi A · April 25, 2015
I would suggest to look for errors in logcat and do accordingly. I encountered the same with Services ( Video 42) and it was related to memory leak. I was clicking a button for which I didn't write any code and it lead to the error.  Rearranging some UI in your code might help, I guess.
0 Faruq Kazi · June 16, 2015
Thank you very much for the replay..I am totally new in Java, came from VB.NET background.. I have to go thru a long way 
  • 1

Java / Android Development

106,920 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator