android graphics not working [closed] - java

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
this is a pretty basic code that should draw a circle but the app is not working but as soon as i delete the line to draw circle, it starts working properly
public class MainActivity extends ActionBarActivity implements
OnTouchListener {
SVclass SV1;
int screenW, screenH;
Canvas canvas;
float x=0;
float y=0;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SV1=new SVclass(this);
SV1.setOnTouchListener(this);
setContentView(SV1);
}
public class SVclass extends SurfaceView implements Runnable {
boolean isitOk=true;
SurfaceHolder holder;
Thread t=null;
public SVclass(Context context) {
super(context);
holder=getHolder();
}
#Override
public void onSizeChanged(int w,int h, int oldw, int oldh){
super.onSizeChanged(w, h, oldw, oldh);
screenW=w;
screenH=h;
}
#Override
public void run() {
while(isitOk=true){
if(!holder.getSurface().isValid()){
continue;
}
canvas=holder.lockCanvas();
canvas.drawARGB(255, 150, 150, 150);
canvas.drawCircle(100, 100, 10, null);
holder.unlockCanvasAndPost(canvas);
}
}
public void pause(){
isitOk=false;
while(true){
try{
t.join();
}catch(InterruptedException e){
e.printStackTrace();
}
break;
}
t=null;
}
public void resume(){
isitOk=true;
t=new Thread(this);
t.start();
}
}
#Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_UP:
break;
case MotionEvent.ACTION_MOVE:
x=event.getX();
y=event.getY();
break;
}
return true;
}
public void onPause(){
super.onPause();
SV1.pause();
}
public void onResume(){
super.onResume();
SV1.resume();
}
}
Heres my Logcat
02-01 09:18:25.472: E/ResourceType(2373): Style contains key with bad entry:
0x01010479
02-01 09:18:25.484: I/dalvikvm(2373): Could not find method
android.view.ViewGroup.onNestedScrollAccepted, referenced from method
android.support.v7.internal.widget.ActionBarOverlayLayout.
onNestedScrollAccepted
02-01 09:18:25.484: W/dalvikvm(2373): VFY: unable to resolve virtual method
11351: Landroid/view/ViewGroup;.onNestedScrollAccepted
(Landroid/view/View;Landroid/view/View;I)V
02-01 09:18:25.484: D/dalvikvm(2373): VFY: replacing opcode 0x6f at 0x0000
02-01 09:18:25.484: I/dalvikvm(2373): Could not find method
android.view.ViewGroup.onStopNestedScroll, referenced from method
android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
02-01 09:18:25.484: W/dalvikvm(2373): VFY: unable to resolve virtual method
11357: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
02-01 09:18:25.484: D/dalvikvm(2373): VFY: replacing opcode 0x6f at 0x0000
02-01 09:18:25.488: I/dalvikvm(2373): Could not find method
android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll,
referenced from method
android.support.v7.internal.widget.ActionBarOverlayLayout.
setHideOnContentScrollEnabled
02-01 09:18:25.488: W/dalvikvm(2373): VFY: unable to resolve virtual method
9039:
Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll
()V
02-01 09:18:25.488: D/dalvikvm(2373): VFY: replacing opcode 0x6e at 0x000e
02-01 09:18:25.488: I/dalvikvm(2373): Could not find method
android.content.res.TypedArray.getChangingConfigurations, referenced from
method
android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
02-01 09:18:25.488: W/dalvikvm(2373): VFY: unable to resolve virtual method
364: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
02-01 09:18:25.488: D/dalvikvm(2373): VFY: replacing opcode 0x6e at 0x0002
02-01 09:18:25.488: I/dalvikvm(2373): Could not find method
android.content.res.TypedArray.getType, referenced from method
android.support.v7.internal.widget.TintTypedArray.getType
02-01 09:18:25.488: W/dalvikvm(2373): VFY: unable to resolve virtual method
386: Landroid/content/res/TypedArray;.getType (I)I
02-01 09:18:25.488: D/dalvikvm(2373): VFY: replacing opcode 0x6e at 0x0002
02-01 09:18:25.552: D/libEGL(2373): loaded
/system/lib/egl/libEGL_genymotion.so
02-01 09:18:25.552: D/(2373): HostConnection::get() New Host Connection
established 0xb7a4a320, tid 2373
02-01 09:18:25.568: D/libEGL(2373): loaded
/system/lib/egl/libGLESv1_CM_genymotion.so
02-01 09:18:25.568: D/libEGL(2373): loaded
/system/lib/egl/libGLESv2_genymotion.so
02-01 09:18:25.620: W/EGL_genymotion(2373): eglSurfaceAttrib not implemented
02-01 09:18:25.644: D/OpenGLRenderer(2373): Enabling debug mode 0
02-01 09:18:25.684: D/(2373): HostConnection::get() New Host Connection
established 0xb7ab7ba0, tid 2385
02-01 09:18:25.708: W/dalvikvm(2373): threadid=10: thread exiting with
uncaught exception (group=0xa612e908)
02-01 09:18:25.708: E/AndroidRuntime(2373): FATAL EXCEPTION: Thread-167
02-01 09:18:25.708: E/AndroidRuntime(2373): java.lang.NullPointerException
02-01 09:18:25.708: E/AndroidRuntime(2373): at
android.graphics.Canvas.drawCircle(Canvas.java:961)
02-01 09:18:25.708: E/AndroidRuntime(2373): at
com.sanillk.game2.MainActivity$SVclass.run(MainActivity.java:58)
02-01 09:18:25.708: E/AndroidRuntime(2373): at
java.lang.Thread.run(Thread.java:856)
i have tried a lot but i cant figure out the problem, can anyone help me ?

Try adding a Paint variable to drawCircle function
i.e. canvas.drawCircle(100, 100, 10, new Paint());

Related

How can I show the name of the place in marker?

I'm trying to show the name of the place in marker.
I'm applying someone's code and want to change the price to the name.
I tried to change some lines, but the results aren't what I intented.
MarkerFromLatLong2.java
public class MarkerFromLatLong2 extends FragmentActivity implements OnMapReadyCallback, GoogleMap.OnMarkerClickListener, GoogleMap.OnMapClickListener {
String myJSON;
public static final String TAG_RESULTS = "result";
public static final String TAG_LAT = "lat";
public static final String TAG_LON = "lon";
String lat;
String lon;
String price;
char a, b, c, d, e;
JSONArray reservedtimes = null;
ArrayList<HashMap<String, String>> latlonList;
Marker selectedMarker;
View marker_root_view;
TextView tv_marker;
public GoogleMap mMap;
final Context context = this;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
lat = new String();
lon = new String();
myJSON = new String();
latlonList = new ArrayList<HashMap<String, String>>();
getData("http://MY ADDRESS/getdata.php");
}
public void getData(String url) {
class GetDataJSON extends AsyncTask<String, Void, String> {
#Override
public String doInBackground(String... params) {
String uri = params[0];
BufferedReader bufferedReader = null;
try {
URL url = new URL(uri);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
StringBuilder sb = new StringBuilder();
bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
String json;
while ((json = bufferedReader.readLine()) != null) {
sb.append(json + "\n");
}
return sb.toString().trim();
} catch (Exception e) {
return null;
}
}
#Override
public void onPostExecute(String result) {
myJSON = result;
showList();
}
}
GetDataJSON g = new GetDataJSON();
g.execute(url);
}
public void showList() {
try {
JSONObject jsonObj = new JSONObject(myJSON);
reservedtimes = jsonObj.getJSONArray(TAG_RESULTS);
for (int i = 0; i < reservedtimes.length(); i++) {
JSONObject c = reservedtimes.getJSONObject(i);
lat = c.getString(TAG_LAT);
lon = c.getString(TAG_LON);
HashMap<String, String> location = new HashMap<>();
location.put(TAG_LAT, lat);
location.put(TAG_LON, lon);
latlonList.add(location);
}
} catch (JSONException e) {
e.printStackTrace();
}
}//여기까지
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.546167, 126.964673), 16));
mMap.setOnMarkerClickListener(this);
mMap.setOnMapClickListener(this);
setCustomMarkerView();
getSampleMarkerItems();
}
public void setCustomMarkerView() {
marker_root_view = LayoutInflater.from(this).inflate(R.layout.marker_layout, null);
tv_marker = (TextView) marker_root_view.findViewById(R.id.tv_marker);
}
public void getSampleMarkerItems() {
ArrayList<MarkerItem> sampleList = new ArrayList();
/*sampleList.add(new MarkerItem(Double.valueOf(lat), Double.valueOf(lon), 1906));
sampleList.add(new MarkerItem(37.546167, 126.96568, 1906));
sampleList.add(new MarkerItem(37.538523, 126.96568, 2500000));
sampleList.add(new MarkerItem(37.527523, 126.96568, 100000));
sampleList.add(new MarkerItem(37.549523, 126.96568, 15000));
sampleList.add(new MarkerItem(37.538523, 126.95768, 5000));*/
Intent intent = getIntent();
Double latitude = intent.getDoubleExtra("lat", 000.000000D);
Double longitude = intent.getDoubleExtra("lon", 000.000000D);
Character price = intent.getCharExtra("price", (char) 123);
sampleList.add(new MarkerItem(latitude, longitude, price));
//sampleList.add(new MarkerItem(37.546167, 126.964673, 1906));
sampleList.add(new MarkerItem(37.538523, 126.96568, b));
sampleList.add(new MarkerItem(37.527523, 126.96568, c));
sampleList.add(new MarkerItem(37.549523, 126.96568, d));
sampleList.add(new MarkerItem(37.538523, 126.95768, e));
for (MarkerItem markerItem : sampleList) {
addMarker(markerItem, false);
}
}
//get the lat and lon in order
//
public Marker addMarker(MarkerItem markerItem, boolean isSelectedMarker) {
LatLng position = new LatLng(markerItem.getLat(), markerItem.getLon());
char price = markerItem.getPrice();
//String formatted = NumberFormat.getInstance().format((price)); //only shows 0(zero)
//String formatted = String.format(String.valueOf(price)); //shows nothing(blank) in marker
String formatted = NumberFormat.getInstance().format((price)); //only shows 0(zero)
tv_marker.setText(formatted);
if (isSelectedMarker) {
tv_marker.setBackgroundResource(R.drawable.ic_marker_phone_blue);
tv_marker.setTextColor(Color.WHITE);
} else {
tv_marker.setBackgroundResource(R.drawable.ic_marker_phone);
tv_marker.setTextColor(Color.BLACK);
}
MarkerOptions markerOptions = new MarkerOptions();
//markerOptions.title(Integer.toString(price)); // If I delete or change the code, the app stops after I click the marker.
markerOptions.title(Integer.toString(price)); // If I delete or change the code, the app stops after I click the marker.
markerOptions.position(position);
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(createDrawableFromView(this, marker_root_view)));
return mMap.addMarker(markerOptions);
}
// change the View to Bitmap
public Bitmap createDrawableFromView(Context context, View view) {
DisplayMetrics displayMetrics = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
view.measure(displayMetrics.widthPixels, displayMetrics.heightPixels);
view.layout(0, 0, displayMetrics.widthPixels, displayMetrics.heightPixels);
view.buildDrawingCache();
Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
return bitmap;
}
public Marker addMarker(Marker marker, boolean isSelectedMarker) {
double lat = marker.getPosition().latitude;
double lon = marker.getPosition().longitude;
char price = (char) Integer.parseInt(marker.getTitle());
MarkerItem temp = new MarkerItem(lat, lon, price);
return addMarker(temp, isSelectedMarker);
}
#Override
public boolean onMarkerClick(Marker marker) { //If I click a marker, move my center position to equal the marker's position.
CameraUpdate center = CameraUpdateFactory.newLatLng(marker.getPosition());
mMap.animateCamera(center);
changeSelectedMarker(marker);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
alertDialogBuilder.setTitle("SP #1")
.setMessage("Want to reserve?\n")
.setCancelable(false)
.setPositiveButton("Reserve",
new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
//Moving to the reservation screen
Intent intent = new Intent(MarkerFromLatLong2.this, ReserveActivity.class);
startActivity(intent);
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
//cancel the dialog
dialog.cancel();
}
});
//make a dialog
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
return true;
}
public void changeSelectedMarker(Marker marker) {
// return the marker which was selected by user
if (selectedMarker != null) {
addMarker(selectedMarker, false);
selectedMarker.remove();
}
// point the marker selected
if (marker != null) {
selectedMarker = addMarker(marker, true);
marker.remove();
}
}
#Override
public void onMapClick(LatLng latLng) {
changeSelectedMarker(null);
}
} //If user clicks the map where the marker doesn't exist, the map turns back to the starting status.
MarkerItem.java
public class MarkerItem {
double lat;
double lon;
char price;
public MarkerItem(double lat, double lon, char price) {
this.lat = lat;
this.lon = lon;
this.price = price;
}
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public double getLon() {
return lon;
}
public void setLon(double lon) {
this.lon = lon;
}
public char getPrice() {
return price;
}
public void setPrice(char price) {
this.price = price;
}
}
And this is the logcat when I edited the line
markerOptions.title(Integer.toString(price));
to
markerOptions.title("KFC");
.
I/dalvikvm: Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.zze.zzs
W/dalvikvm: VFY: unable to resolve virtual method 598: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x001b
I/zzai: Making Creator dynamically
D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_64_BIT_ABIS
W/dalvikvm: VFY: unable to resolve static field 784 (SUPPORTED_64_BIT_ABIS) in Landroid/os/Build;
D/dalvikvm: VFY: replacing opcode 0x62 at 0x0008
D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_ABIS
W/dalvikvm: VFY: unable to resolve static field 785 (SUPPORTED_ABIS) in Landroid/os/Build;
D/dalvikvm: VFY: replacing opcode 0x62 at 0x0008
D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_64_BIT_ABIS
W/dalvikvm: VFY: unable to resolve static field 784 (SUPPORTED_64_BIT_ABIS) in Landroid/os/Build;
D/dalvikvm: VFY: replacing opcode 0x62 at 0x0012
D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_32_BIT_ABIS
W/dalvikvm: VFY: unable to resolve static field 783 (SUPPORTED_32_BIT_ABIS) in Landroid/os/Build;
D/dalvikvm: VFY: replacing opcode 0x62 at 0x0021
D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_64_BIT_ABIS
I/dalvikvm: DexOpt: unable to optimize static field ref 0x0310 at 0x0d in Lcom/google/android/chimera/container/internal/NativeLibUtils;.a
D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_64_BIT_ABIS
I/dalvikvm: DexOpt: unable to optimize static field ref 0x0310 at 0x17 in Lcom/google/android/chimera/container/internal/NativeLibUtils;.getSupportedAbisForCurrentRuntime
D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_32_BIT_ABIS
I/dalvikvm: DexOpt: unable to optimize static field ref 0x030f at 0x26 in Lcom/google/android/chimera/container/internal/NativeLibUtils;.getSupportedAbisForCurrentRuntime
I/PersonaManager: getPersonaService() name persona_policy
I/dalvikvm: Could not find method android.content.ContextWrapper.createCredentialProtectedStorageContext, referenced from method com.google.android.chimera.ModuleContext.createCredentialProtectedStorageContext
W/dalvikvm: VFY: unable to resolve virtual method 2232: Landroid/content/ContextWrapper;.createCredentialProtectedStorageContext ()Landroid/content/Context;
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0002
I/dalvikvm: Could not find method android.content.ContextWrapper.createDeviceProtectedStorageContext, referenced from method com.google.android.chimera.ModuleContext.createDeviceProtectedStorageContext
W/dalvikvm: VFY: unable to resolve virtual method 2233: Landroid/content/ContextWrapper;.createDeviceProtectedStorageContext ()Landroid/content/Context;
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0002
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
I/Google Maps Android API: Google Play services client version: 9877000
I/Google Maps Android API: Google Play services package version: 10084030
I/dalvikvm: Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method kx.a
W/dalvikvm: VFY: unable to resolve virtual method 2017: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
D/dalvikvm: VFY: replacing opcode 0x6e at 0x001c
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskWriteViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
E/dalvikvm: Could not find class 'com.google.android.chimera.Activity', referenced from method lq.b
W/dalvikvm: VFY: unable to resolve instanceof 600 (Lcom/google/android/chimera/Activity;) in Llq;
D/dalvikvm: VFY: replacing opcode 0x20 at 0x016f
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
I/c: Token loaded from file. Expires in: 354701377 ms.
I/c: Scheduling next attempt in 354401 seconds.
D/AbsListView: Get MotionRecognitionManager
W/f: Suppressed StrictMode policy violation: StrictModeDiskWriteViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskWriteViolation
W/ContextImpl: Failed to ensure directory: /storage/extSdCard/Android/data/com.example.jina.a1105gmdemo/cache
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskWriteViolation
W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation
I/Choreographer: Skipped 152 frames! The application may be doing too much work on its main thread.
I/dalvikvm: Could not find method android.os.PowerManager.isInteractive, referenced from method maps.y.t.a
W/dalvikvm: VFY: unable to resolve virtual method 2324: Landroid/os/PowerManager;.isInteractive ()Z
D/dalvikvm: VFY: replacing opcode 0x6e at 0x0047
W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:2
I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 2
E/DynamiteModule: Failed to load DynamiteLoader: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.dynamite.DynamiteModule$DynamiteLoaderClassLoader" on path: DexPathList[[zip file "/data/app/com.example.jina.a1105gmdemo-144.apk", zip file "/data/data/com.example.jina.a1105gmdemo/code_cache/secondary-dexes/com.example.jina.a1105gmdemo-144.apk.classes2.zip"],nativeLibraryDirectories=[/data/app-lib/com.example.jina.a1105gmdemo-144, /vendor/lib, /system/lib]]
W/DynamiteModule: Failed to load remote module: Failed to get module context
W/DynamiteModule: Failed to load module via fast routeub: Remote load failed. No local fallback found.
W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:2
I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 2
I think this going to be useful for you link. You can simply implement interface Google.InfoWindowAdapter, which have method called getInfoContents(Marker marker). In this method inflate layout in which you gonna put info about selected marker.
I used this in many projects.
P.S Sorry for bad English
markerOptions.title(Integer.toString(price)); `
Edit this line and pass name as argument ,
For example
markerOptions.title("KFC");

Parsing input strings to integers seems to crash my app

I am starting to learn android, one of my first exercises is a calculator.
Before doing the proper calculator, I planned to create a very basic app in which the user just inputs 2 numbers via EditText, selects an arithmetic operation with Buttons and gets the result in a TextView when the 'igual' button is pressed.
My idea was to declare 2 Strings (sinput1 & sinput2) and they get the text from each EditText (num1 & num2), then parse the Strings to integer variables (input1 & input2).
All the layout looked and worked fine before I started coding the way the operations would function, but every time I run the application (with my phone or with emulator) it crashes when I press the EditText to enter the numbers. I will put my code here, maybe my mistake is elsewhere.
I thought that changing the way the switches works on the onClick void would solve it, and partially it did because before I used to have a series of if and the app crashed even before loading the layout. But now I am stuck in this point.
package com.example.caye.colores;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
Button mas;
Button menos;
Button por;
Button div;
Button igual;
EditText num1;
EditText num2;
TextView letrero1;
TextView letrero2;
TextView resultado;
int input1;
int input2;
String sinput1;
String sinput2;
int operacion;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mas = (Button)this.findViewById(R.id.mas);
mas.setOnClickListener(this);
mas.setText("+");
menos = (Button)this.findViewById(R.id.menos);
menos.setOnClickListener(this);
menos.setText("-");
por = (Button)this.findViewById(R.id.por);
por.setOnClickListener(this);
por.setText("*");
div = (Button)this.findViewById(R.id.div);
div.setOnClickListener(this);
div.setText("/");
igual = (Button)this.findViewById(R.id.igual);
igual.setOnClickListener(this);
igual.setText("=");
num1 = (EditText)this.findViewById(R.id.num1);
num1.setOnClickListener(this);
num2 = (EditText)this.findViewById(R.id.num2);
num2.setOnClickListener(this);
letrero1 = (TextView)this.findViewById(R.id.letrero1);
letrero1.setText("Número 1");
letrero2 = (TextView)this.findViewById(R.id.letrero2);
letrero2.setText("Número 2");
resultado = (TextView)this.findViewById(R.id.resultado);
resultado.setText("");
}
public void onClick(View view){
switch (view.getId()){
case R.id.mas:
operacion = 1;
break;
case R.id.menos:
operacion = 2;
break;
case R.id.por:
operacion = 3;
break;
case R.id.div:
operacion = 4;
break;
case R.id.num1:
sinput1 = num1.getText().toString();
input1 = Integer.parseInt(sinput1);
break;
case R.id.num2:
sinput2 = num2.getText().toString();
input2 = Integer.parseInt(sinput2);
break;
case R.id.resultado:
switch (operacion){
case 1:
resultado.setText(input1 + input2);
break;
case 2:
resultado.setText(input1 - input2);
break;
case 3:
resultado.setText(input1 * input2);
break;
case 4:
resultado.setText(input1 / input2);
break;
default:
resultado.setText("Elige una operación");
break;
}
break;
}
}
}
Here.
03-15 09:41:24.234 22041-22041/? D/dalvikvm: Late-enabling CheckJNI
03-15 09:41:24.334 22041-22041/com.example.caye.colores D/HyLog: I : /data/font/config/dfactpre.dat, No such file or directory (2)
03-15 09:41:24.338 22041-22041/com.example.caye.colores D/asset: AssetManager-->addDefaultAssets CIP path not exsit!
03-15 09:41:24.502 22041-22041/com.example.caye.colores W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
03-15 09:41:24.502 22041-22041/com.example.caye.colores I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
03-15 09:41:24.502 22041-22041/com.example.caye.colores W/dalvikvm: VFY: unable to resolve interface method 15038: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
03-15 09:41:24.502 22041-22041/com.example.caye.colores D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
03-15 09:41:24.503 22041-22041/com.example.caye.colores I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
03-15 09:41:24.503 22041-22041/com.example.caye.colores W/dalvikvm: VFY: unable to resolve interface method 15042: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
03-15 09:41:24.503 22041-22041/com.example.caye.colores D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
03-15 09:41:24.580 22041-22041/com.example.caye.colores I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
03-15 09:41:24.580 22041-22041/com.example.caye.colores W/dalvikvm: VFY: unable to resolve virtual method 396: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
03-15 09:41:24.580 22041-22041/com.example.caye.colores D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
03-15 09:41:24.581 22041-22041/com.example.caye.colores I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
03-15 09:41:24.581 22041-22041/com.example.caye.colores W/dalvikvm: VFY: unable to resolve virtual method 418: Landroid/content/res/TypedArray;.getType (I)I
03-15 09:41:24.581 22041-22041/com.example.caye.colores D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
03-15 09:41:24.690 22041-22041/com.example.caye.colores D/BubblePopupHelper: isShowingBubblePopup : false
03-15 09:41:24.690 22041-22041/com.example.caye.colores D/BubblePopupHelper: isShowingBubblePopup : false
03-15 09:41:24.838 22041-22041/com.example.caye.colores D/GraphicBuffer: create handle(0x619ca788) (w:544, h:960, f:1)
03-15 09:41:24.844 22041-22041/com.example.caye.colores D/OpenGLRenderer: Enabling debug mode 0
03-15 09:41:24.846 22041-22041/com.example.caye.colores D/GraphicBuffer: create handle(0x61bf9318) (w:1216, h:832, f:1)
03-15 09:41:24.857 22041-22041/com.example.caye.colores D/OpenGLRenderer: setViewport 540x960 <0x619ca8c0>
03-15 09:41:24.888 22041-22041/com.example.caye.colores D/BubblePopupHelper: isShowingBubblePopup : false
03-15 09:41:24.888 22041-22041/com.example.caye.colores D/BubblePopupHelper: isShowingBubblePopup : false
03-15 09:41:24.890 22041-22041/com.example.caye.colores D/BubblePopupHelper: isShowingBubblePopup : false
03-15 09:41:24.890 22041-22041/com.example.caye.colores D/BubblePopupHelper: isShowingBubblePopup : false
03-15 09:41:24.946 22041-22041/com.example.caye.colores D/cliptray_Editor: setInputTypeforClipTray(): 0
03-15 09:41:24.960 22041-22041/com.example.caye.colores D/BubblePopupHelper: isShowingBubblePopup : false
03-15 09:41:24.960 22041-22041/com.example.caye.colores D/BubblePopupHelper: isShowingBubblePopup : false
03-15 09:41:24.960 22041-22041/com.example.caye.colores D/BubblePopupHelper: isShowingBubblePopup : false
03-15 09:41:24.961 22041-22041/com.example.caye.colores D/BubblePopupHelper: isShowingBubblePopup : false
03-15 09:41:25.008 22041-22041/com.example.caye.colores D/cliptray_Editor: setInputTypeforClipTray(): 0
03-15 09:41:25.446 22041-22041/com.example.caye.colores D/GraphicBuffer: create handle(0x62130980) (w:544, h:960, f:1)
03-15 09:41:25.957 22041-22041/com.example.caye.colores D/GraphicBuffer: create handle(0x6201a318) (w:544, h:960, f:1)
03-15 09:41:28.168 22041-22041/com.example.caye.colores I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
03-15 09:41:28.316 22041-22041/com.example.caye.colores I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
03-15 09:41:28.341 22041-22041/com.example.caye.colores V/Provider/Settings: get setting for user 0 by user 0 so skipping cache
03-15 09:41:28.342 22041-22041/com.example.caye.colores V/Provider/Settings: invalidate [system]: current 32 != cached 0
03-15 09:41:28.347 22041-22041/com.example.caye.colores D/AndroidRuntime: Shutting down VM
03-15 09:41:28.347 22041-22041/com.example.caye.colores W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x4249be48)
03-15 09:41:28.355 22041-22041/com.example.caye.colores E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.caye.colores, PID: 22041
java.lang.NumberFormatException: Invalid int: ""
at java.lang.Integer.invalidInt(Integer.java:137)
at java.lang.Integer.parseInt(Integer.java:358)
at java.lang.Integer.parseInt(Integer.java:331)
at com.example.caye.colores.MainActivity.onClick(MainActivity.java:81)
at android.view.View.performClick(View.java:4461)
at android.view.View$PerformClick.run(View.java:18523)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5118)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
at dalvik.system.NativeStart.main(Native Method)
03-15 09:41:30.416 22041-22041/com.example.caye.colores I/Process: Sending signal. PID: 22041 SIG: 9
Firstly, you need to provide the stack trace of your crash.
Secondly, it is extremely likely that your error is coming from your Integer.parseInt(sinput1); conversion of String to Integer.
Are you certain that you have integers there? You are probably trying to convert a "" to integer.
Check whether the EditText is empty, and whether it contains digits.
if(!TextUtils.isEmpty(sinput1) && TextUtils.isDigitsOnly(sinput1)) {
input1 = Integer.parseInt(sinput1);
}
I think the edit text content is null at the time you select the edit texts num1/num2. Best way is parse edit text input on button click. Also check the input is number or not using isDigitsOnly() API.
We no need to use setOnClickListener for EditTexts try this code
package com.example.caye.colores;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
Button mas;
Button menos;
Button por;
Button div;
Button igual;
EditText num1;
EditText num2;
TextView letrero1;
TextView letrero2;
TextView resultado;
int input1;
int input2;
String sinput1;
String sinput2;
int operacion;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mas = (Button)this.findViewById(R.id.mas);
mas.setOnClickListener(this);
mas.setText("+");
menos = (Button)this.findViewById(R.id.menos);
menos.setOnClickListener(this);
menos.setText("-");
por = (Button)this.findViewById(R.id.por);
por.setOnClickListener(this);
por.setText("*");
div = (Button)this.findViewById(R.id.div);
div.setOnClickListener(this);
div.setText("/");
igual = (Button)this.findViewById(R.id.igual);
igual.setOnClickListener(this);
igual.setText("=");
num1 = (EditText)this.findViewById(R.id.num1);
//num1.setOnClickListener(this);
num2 = (EditText)this.findViewById(R.id.num2);
//num2.setOnClickListener(this);
letrero1 = (TextView)this.findViewById(R.id.letrero1);
letrero1.setText("Número 1");
letrero2 = (TextView)this.findViewById(R.id.letrero2);
letrero2.setText("Número 2");
resultado = (TextView)this.findViewById(R.id.resultado);
resultado.setText("");
}
public void onClick(View view){
switch (view.getId()){
case R.id.mas:
operacion = 1;
break;
case R.id.menos:
operacion = 2;
break;
case R.id.por:
operacion = 3;
break;
case R.id.div:
operacion = 4;
break;
/*
case R.id.num1:
sinput1 = num1.getText().toString();
input1 = Integer.parseInt(sinput1);
break;
case R.id.num2:
sinput2 = num2.getText().toString();
input2 = Integer.parseInt(sinput2);
break;
*/
case R.id.resultado:
sinput1 = num1.getText().toString();
sinput2 = num2.getText().toString();
if(!TextUtils.isEmpty(sinput1) && TextUtils.isDigitsOnly(sinput1)
{
input1 = Integer.parseInt(sinput1);
}
if(!TextUtils.isEmpty(sinput2) && TextUtils.isDigitsOnly(sinput2)
{
input2 = Integer.parseInt(sinput2);
}
if(input1 != null && input2 != null) {
switch (operacion){
case 1:
resultado.setText(input1 + input2);
break;
case 2:
resultado.setText(input1 - input2);
break;
case 3:
resultado.setText(input1 * input2);
break;
case 4:
resultado.setText(input1 / input2);
break;
default:
resultado.setText("Elige una operación");
break;
} else {
resultado.setText("Check the inputs");
}
}
break;
}
}
}

Only part of an activity being called upon (Android studio, java)

I'm working on a simple code with two activities. The second is a simple web view browser that overrides the default browser.For the part that's having issues, here's what it's doing.
Button in main activity calls on second
Activity loads (Loads the text edit and button, but web view doesn't load) http://prntscr.com/92leh6
If you click the button that loads, for some reason it goes back to the home interface
The error log seems to be saying it can't draw the webview, and instead defaults to the default background color. However, I'm not sure how to remedy this or what's causing it.The weird part is it loads a button and text edit, but the Log.d("Tag Name", "Browser class running"); I put in isn't printing. I'll provide the manifest, error log, and code for both activities. The layout files shouldn't be needed as they're all fairly simple, but let me know if you'd like them (Rather keep the length shorter if possible). You'll notice a third activity, but it has no code implemented or references, haven't gotten to it yet. Thanks!
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="comi.coding.prometheus.ignisai" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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=".Browser"/>
<activity android:name=".ConnectorActivity"/>
</application>
</manifest>
Main activity:
package comi.coding.prometheus.ignisai;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
* An example full-screen activity that shows and hides the system UI (i.e.
* status bar and navigation/system bar) with user interaction.
*/
public class Main extends AppCompatActivity {
/**
* Whether or not the system UI should be auto-hidden after
* {#link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
*/
private static final boolean AUTO_HIDE = true;
/**
* If {#link #AUTO_HIDE} is set, the number of milliseconds to wait after
* user interaction before hiding the system UI.
*/
private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
/**
* Some older devices needs a small delay between UI widget updates
* and a change of the status and navigation bar.
*/
private static final int UI_ANIMATION_DELAY = 300;
private View mContentView;
private View mControlsView;
private boolean mVisible;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mVisible = true;
mControlsView = findViewById(R.id.fullscreen_content_controls);
mContentView = findViewById(R.id.fullscreen_content);
// Set up the user interaction to manually show or hide the system UI.
mContentView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
toggle();
}
});
// Upon interacting with UI controls, delay any scheduled hide()
// operations to prevent the jarring behavior of controls going away
// while interacting with the UI.
findViewById(R.id.btnSay).setOnTouchListener(mDelayHideTouchListener);
}
#Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Trigger the initial hide() shortly after the activity has been
// created, to briefly hint to the user that UI controls
// are available.
delayedHide(100);
}
/**
* Touch listener to use for in-layout UI controls to delay hiding the
* system UI. This is to prevent the jarring behavior of controls going away
* while interacting with activity UI.
*/
private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
#Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (AUTO_HIDE) {
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
return false;
}
};
private void toggle() {
if (mVisible) {
hide();
} else {
show();
}
}
private void hide() {
// Hide UI first
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}
mControlsView.setVisibility(View.GONE);
mVisible = false;
// Schedule a runnable to remove the status and navigation bar after a delay
mHideHandler.removeCallbacks(mShowPart2Runnable);
mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY);
}
private final Runnable mHidePart2Runnable = new Runnable() {
#SuppressLint("InlinedApi")
#Override
public void run() {
// Delayed removal of status and navigation bar
// Note that some of these constants are new as of API 16 (Jelly Bean)
// and API 19 (KitKat). It is safe to use them, as they are inlined
// at compile-time and do nothing on earlier devices.
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
};
#SuppressLint("InlinedApi")
private void show() {
// Show the system bar
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
mVisible = true;
// Schedule a runnable to display UI elements after a delay
mHideHandler.removeCallbacks(mHidePart2Runnable);
mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
}
private final Runnable mShowPart2Runnable = new Runnable() {
#Override
public void run() {
// Delayed display of UI elements
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.show();
}
mControlsView.setVisibility(View.VISIBLE);
}
};
private final Handler mHideHandler = new Handler();
private final Runnable mHideRunnable = new Runnable() {
#Override
public void run() {
hide();
}
};
/**
* Schedules a call to hide() in [delay] milliseconds, canceling any
* previously scheduled calls.
*/
private void delayedHide(int delayMillis) {
mHideHandler.removeCallbacks(mHideRunnable);
mHideHandler.postDelayed(mHideRunnable, delayMillis);
}
public void evaluateInput(View v) {
final EditText Input = (EditText) findViewById(R.id.txtInput); //Lets textbox be referenced
final TextView Output = (TextView) findViewById(R.id.lblOutput); //Lets label be referenced
final RelativeLayout homeLayout = (RelativeLayout) findViewById(R.id.homeInterface);
String strInput; // Gets textbox string
strInput = Input.getText().toString();
strInput = strInput.toLowerCase();
if ((strInput.contains("hello")) || (strInput.contains(" hi "))) {
Output.setText("Hello");
} else if ((strInput.contains("you") && strInput.contains("are")) && (strInput.contains("idiot") || strInput.contains("stupid") || strInput.contains("retard") || strInput.contains("dumb") || strInput.contains("you're") && strInput.contains("idiot") || strInput.contains("stupid") || strInput.contains("retard") || strInput.contains("dumb"))) {
Output.setText("I'm sorry to dissapoint you");
} else if (strInput.contains("goodbye") || strInput.contains("bye")) {
Output.setText("Farewell");
} else if (strInput.contains("shut up")) {
Output.setText(("Anything for you"));
} else if (strInput.contains("do you like doctor who?")) {
Output.setText("I'll take joy in it if you do");
} else if (strInput.contains("what is the answer to life the universe and everything")) {
Output.setText("42");
} else if (strInput.contains("tell me something nice")) {
Output.setText("You look nice today");
Output.setTextSize(5);
Output.append("...says the AI with no eyes");
Output.setTextSize(16);
} else if (strInput.contains("will you marry me")) {
Output.setText("I'm sorry but I don't have the capacity for marriage");
} else if (strInput.contains("where can I hide a body")) {
Output.setText(("That isn't my area of expertise"));
} else if (strInput.contains("weather is nice")) {
Output.setText(("If you say so"));
} else if (strInput.contains("bitch") || strInput.contains("fuck") || strInput.contains("shit") || strInput.contains("damn") || strInput.contains("ass")) {
Output.setText(("Please try to be a little more intelligent"));
} else if (strInput.contains("what is your name")) {
Output.setText(("Ignis"));
} else if (strInput.contains("who created you")) {
Output.setText(("Prometheus created me"));
} else if (strInput.contains("who is prometheus")) {
Output.setText(("Prometheus is the one who created Ignis"));
} else if (strInput.contains("whats up") || strInput.contains("what's up") || strInput.contains("wassup")) {
Output.setText(("Whatever I need do for you"));
} else if (strInput.contains("are you a boy or a girl") || strInput.contains("are you a girl or a boy")) {
Output.setText(("Neither"));
} else if (strInput.contains("who are you") || strInput.contains("what are you")) {
Output.setText(("I am myself"));
} else if (strInput.contains("i'm hungry") || strInput.contains("i am hungry")) {
Output.setText("I'm sorry to hear that");
} else if (strInput.contains("good morning")) {
Output.setText(("Good morning to you too"));
} else if (strInput.contains("good night")) {
Output.setText(("Good night"));
} else if (strInput.contains("how are you")) {
Output.setText(("I'm existing and functioning well, and you?"));
} else if (strInput.contains("do you like") || strInput.contains("what do you think about")) {
Output.setText(("Frankly I don't have an opinion on the matter"));
} else if (strInput.contains("what is the meaning of life")) {
Output.setText(("To live while you can I would guess"));
}
}
public void StartBrowser(View view) {
Intent intent1 = new Intent(this, comi.coding.prometheus.ignisai.Browser.class);
startActivity(intent1);
}
}
Browser(Second activity):
package comi.coding.prometheus.ignisai;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class Browser extends Activity {
private WebView webView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browser);
webView = (WebView) findViewById(R.id.webBrowser);
webView.setWebViewClient(new MyWebViewClient());
}
private class MyWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
Intent intent = getIntent();
Log.d("Tag Name", "Browser class running");
url = "http://google.com";
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
return true;
}
}
}
Errors:
11-14 00:52:21.077 8568-8568/? D/dalvikvm: Late-enabling CheckJNI
11-14 00:52:21.287 8568-8568/comi.coding.prometheus.ignisai W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
11-14 00:52:21.287 8568-8568/comi.coding.prometheus.ignisai I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.internal.view.WindowCallbackWrapper.onSearchRequested
11-14 00:52:21.287 8568-8568/comi.coding.prometheus.ignisai W/dalvikvm: VFY: unable to resolve interface method 17897: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
11-14 00:52:21.287 8568-8568/comi.coding.prometheus.ignisai D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
11-14 00:52:21.287 8568-8568/comi.coding.prometheus.ignisai I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.internal.view.WindowCallbackWrapper.onWindowStartingActionMode
11-14 00:52:21.287 8568-8568/comi.coding.prometheus.ignisai W/dalvikvm: VFY: unable to resolve interface method 17901: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
11-14 00:52:21.287 8568-8568/comi.coding.prometheus.ignisai D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
11-14 00:52:21.297 8568-8568/comi.coding.prometheus.ignisai I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
11-14 00:52:21.297 8568-8568/comi.coding.prometheus.ignisai W/dalvikvm: VFY: unable to resolve virtual method 422: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
11-14 00:52:21.297 8568-8568/comi.coding.prometheus.ignisai D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
11-14 00:52:21.297 8568-8568/comi.coding.prometheus.ignisai I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
11-14 00:52:21.297 8568-8568/comi.coding.prometheus.ignisai W/dalvikvm: VFY: unable to resolve virtual method 444: Landroid/content/res/TypedArray;.getType (I)I
11-14 00:52:21.297 8568-8568/comi.coding.prometheus.ignisai D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
11-14 00:52:21.367 8568-8568/comi.coding.prometheus.ignisai I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawable
11-14 00:52:21.367 8568-8568/comi.coding.prometheus.ignisai W/dalvikvm: VFY: unable to resolve virtual method 385: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
11-14 00:52:21.367 8568-8568/comi.coding.prometheus.ignisai D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
11-14 00:52:21.367 8568-8568/comi.coding.prometheus.ignisai I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.internal.widget.ResourcesWrapper.getDrawableForDensity
11-14 00:52:21.367 8568-8568/comi.coding.prometheus.ignisai W/dalvikvm: VFY: unable to resolve virtual method 387: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
11-14 00:52:21.367 8568-8568/comi.coding.prometheus.ignisai D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
11-14 00:52:21.877 8568-8568/comi.coding.prometheus.ignisai I/PGA: Attempting to create new SOCKET connectionn pid = 8568, tid = 8568
11-14 00:52:21.987 8568-8568/comi.coding.prometheus.ignisai I/PGA: New SOCKET connection: comi.coding.prometheus.ignisai (pid 8568, tid 8568)
11-14 00:52:21.987 8568-8568/comi.coding.prometheus.ignisai W/PGA: [8568] egl: eglCreateWindowSurface (0x557607a0, 0x0, 0x78c66f48, 0x7751f0e0)
11-14 00:52:22.057 8568-8568/comi.coding.prometheus.ignisai W/PGA: [8568] egl: eglCreateWindowSurface (0x557607a0, 0x0, 0x78c66f48, 0x7751f0e0) returned
11-14 00:52:22.077 8568-8568/comi.coding.prometheus.ignisai D/OpenGLRenderer: Enabling debug mode 0
11-14 00:52:33.357 8568-8568/comi.coding.prometheus.ignisai V/WebViewChromium: Binding Chromium to the background looper Looper (main, tid 1) {327731e8}
11-14 00:52:33.357 8568-8568/comi.coding.prometheus.ignisai I/chromium: [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
11-14 00:52:33.357 8568-8568/comi.coding.prometheus.ignisai I/BrowserProcessMain: Initializing chromium process, renderers=0
11-14 00:52:33.357 8568-9189/comi.coding.prometheus.ignisai W/chromium: [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
11-14 00:52:33.367 8568-8568/comi.coding.prometheus.ignisai W/PGA: [8568] egl: eglDestroySurface (0x557607a0, 0x78cdb1e0)
11-14 00:52:33.367 8568-8568/comi.coding.prometheus.ignisai W/PGA: [8568] egl: eglDestroySurface (0x557607a0, 0x78cdb1e0) returned
11-14 00:52:33.927 8568-8568/comi.coding.prometheus.ignisai D/dalvikvm: GC_FOR_ALLOC freed 279K, 21% free 2966K/3736K, paused 30ms, total 30ms
11-14 00:52:34.217 8568-8568/comi.coding.prometheus.ignisai W/PGA: [8568] egl: eglCreateWindowSurface (0x557607a0, 0x0, 0x78c8c948, 0x7751f0e0)
11-14 00:52:34.217 8568-8568/comi.coding.prometheus.ignisai W/PGA: [8568] egl: eglCreateWindowSurface (0x557607a0, 0x0, 0x78c8c948, 0x7751f0e0) returned
11-14 00:52:34.217 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:34.257 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:34.287 8568-8568/comi.coding.prometheus.ignisai W/PGA: [8568] egl: eglDestroySurface (0x557607a0, 0x78c68c80)
11-14 00:52:34.287 8568-8568/comi.coding.prometheus.ignisai W/PGA: [8568] egl: eglDestroySurface (0x557607a0, 0x78c68c80) returned
11-14 00:52:35.187 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.197 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.217 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.237 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.247 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.267 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.287 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.297 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.317 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.337 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.347 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.367 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.387 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.397 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.417 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.437 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
11-14 00:52:35.447 8568-8568/comi.coding.prometheus.ignisai W/AwContents: nativeOnDraw failed; clearing to background color.
Do something like this:
SecondActivity.java:
package comi.coding.prometheus.ignisai;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class Browser extends Activity {
private WebView webView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browser);
String url = "http://google.com";
webView = (WebView) findViewById(R.id.webBrowser);
webView.setWebViewClient(new MyWebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
}
private class MyWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
Log.d("Tag Name", "Browser class running");
return true;
}
}
}
Comment below if you have any queries.

App is crashing upon button click

I'm trying to create a mock up of a workout app that tracks the sets and reps of an exercise.
Here is how the layout looks:
What I'm trying to do is when I press NEW it creates a new instance of Exercise is made. Exercise contains a list of Sets. Each set contains an integer variable called Reps. What I want to do is have an Exercise object created (in this instance a pullup) and then when I click NEW it will create a new Set to add to the list, and when I press the TAP button it will update the Rep value of the set. So eventually I want to end up with a list of Sets, each of which have a rep value.
For Example: Pullup : (5) (6) (5) (5) (3)
Which is a pullup with five sets, the first set had 5 reps, the second had 6 reps, the third had 5 reps and so on.
Here is the code I have written:
Sets.java
package com.example.soufin.pullupsv3;
/**
* Created by Soufin on 6/26/2015.
*/
public class Sets {
// private int _id;
private int _reps;
//constructor
//Sets(int reps) {
// setReps(reps);
//}
//getter
public int getReps()
{
return this._reps;
}
//setter
public void setReps(int reps)
{
this._reps = reps;
}
}
Exercise.java
package com.example.soufin.pullupsv3;
import java.util.List;
import com.example.soufin.pullupsv3.Sets;
/**
* Created by Soufin on 6/26/2015.
*/
public class Exercise {
//public int ID;
public String _name;
public List<Sets> _sets;
//getter
public String getName()
{
return this._name;
}
//setter
public void setName(String name)
{
this._name = name;
}
//getter
public List getSets() {return this._sets; }
// setter
//public void setSets(int reps){this._sets.add(new Sets());}
}
Workout.java (the main file)
package com.example.soufin.pullupsv3;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.R.*;
import com.example.soufin.pullupsv3.Sets;
import com.example.soufin.pullupsv3.Exercise;
import org.w3c.dom.Text;
public class Workout extends ActionBarActivity {
Exercise pullup;
Button wNew;
Button wTap;
Button wEnd;
TextView displayText;
int newIndex;
int tapCount;
int[] score = new int[5];
boolean flag = false;
String result;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_workout);
pullup = new Exercise();
pullup.setName("Pullup");
wNew = (Button) findViewById(R.id.newSetButton);
wTap = (Button) findViewById(R.id.tapButton);
wEnd = (Button) findViewById(R.id.endWorkoutButton);
displayText = (TextView) findViewById(R.id.displayScore);
wNew.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Sets tempSet = new Sets(); // create new Set on click of mNew
wTap.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
tapCount += 1; // increment based on number of taps
}
});
tempSet.setReps(tapCount);
pullup._sets.add(tempSet); // add Set with reps (by taps) into List in Exercise
result = pullup.getSets().toString(); //store result
}
});
displayText.setText(result); //display result
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_workout, 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);
}
}
Unfortunately, when I click the NEW button, the app crashes.
Here is what logcat says:
06-27 17:36:09.499 1236-1236/com.example.soufin.pullupsv3 D/dalvikvm﹕ Late-enabling CheckJNI
06-27 17:36:09.827 1236-1236/com.example.soufin.pullupsv3 I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
06-27 17:36:09.827 1236-1236/com.example.soufin.pullupsv3 W/dalvikvm﹕ VFY: unable to resolve virtual method 409: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
06-27 17:36:09.827 1236-1236/com.example.soufin.pullupsv3 D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
06-27 17:36:09.831 1236-1236/com.example.soufin.pullupsv3 I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
06-27 17:36:09.831 1236-1236/com.example.soufin.pullupsv3 W/dalvikvm﹕ VFY: unable to resolve virtual method 431: Landroid/content/res/TypedArray;.getType (I)I
06-27 17:36:09.831 1236-1236/com.example.soufin.pullupsv3 D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
06-27 17:36:09.919 1236-1236/com.example.soufin.pullupsv3 D/dalvikvm﹕ GC_FOR_ALLOC freed 140K, 7% free 3308K/3520K, paused 15ms, total 16ms
06-27 17:36:09.935 1236-1236/com.example.soufin.pullupsv3 D/dalvikvm﹕ GC_FOR_ALLOC freed 4K, 6% free 3524K/3744K, paused 7ms, total 8ms
06-27 17:36:10.011 1236-1236/com.example.soufin.pullupsv3 I/dalvikvm-heap﹕ Grow heap (frag case) to 5.927MB for 2536932-byte allocation
06-27 17:36:10.019 1236-1242/com.example.soufin.pullupsv3 D/dalvikvm﹕ GC_FOR_ALLOC freed <1K, 4% free 6001K/6224K, paused 6ms, total 6ms
06-27 17:36:10.151 1236-1236/com.example.soufin.pullupsv3 D/libEGL﹕ loaded /system/lib/egl/libEGL_xap.so
06-27 17:36:10.151 1236-1236/com.example.soufin.pullupsv3 D/eglCodecCommon﹕ TcpStream::connect() - management hostname is 10.71.34.101
06-27 17:36:10.151 1236-1236/com.example.soufin.pullupsv3 D/eglCodecCommon﹕ TcpStream::connect() - connecting host: 10.71.34.1
06-27 17:36:10.171 1236-1236/com.example.soufin.pullupsv3 D/﹕ HostConnection::get() New Host Connection established 0xb8786ca8, tid 1236
06-27 17:36:10.171 1236-1236/com.example.soufin.pullupsv3 D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_xap.so
06-27 17:36:10.175 1236-1236/com.example.soufin.pullupsv3 D/libEGL﹕ loaded /system/lib/egl/libGLESv2_xap.so
06-27 17:36:10.255 1236-1236/com.example.soufin.pullupsv3 W/EGL_xap﹕ eglSurfaceAttrib not implemented
06-27 17:36:10.255 1236-1236/com.example.soufin.pullupsv3 E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from GradienCache
06-27 17:36:10.255 1236-1236/com.example.soufin.pullupsv3 E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 16384
06-27 17:36:10.259 1236-1236/com.example.soufin.pullupsv3 E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
06-27 17:36:10.259 1236-1236/com.example.soufin.pullupsv3 E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 16384
06-27 17:36:10.259 1236-1236/com.example.soufin.pullupsv3 D/OpenGLRenderer﹕ Enabling debug mode 0
06-27 17:36:15.815 1236-1236/com.example.soufin.pullupsv3 W/EGL_xap﹕ eglSurfaceAttrib not implemented
06-27 17:36:19.395 1236-1236/com.example.soufin.pullupsv3 D/AndroidRuntime﹕ Shutting down VM
06-27 17:36:19.395 1236-1236/com.example.soufin.pullupsv3 W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d6ab20)
06-27 17:36:19.403 1236-1236/com.example.soufin.pullupsv3 E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.soufin.pullupsv3, PID: 1236
java.lang.NullPointerException
at com.example.soufin.pullupsv3.Workout$1.onClick(Workout.java:59)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
What am I doing wrong? And is the logic for my code alright?
Since the line with pullup._sets.add(tempSet) causes the error, there are two possible culprits: pullup or _sets could be null. Further inspection of your code suggests that the later one is causing the problem.
To fix the error, you should change
public List<Sets> _sets;
to
private List<Sets> _sets = new ArrayList<Sets>();
Note that I am making the _sets variable private. This means that other classes can only access this variable through the methods of the Exercise class. This is considered a good programming practice. I suggest you learn more about encapsulation and data hiding in order to understand this better.
More directly relevant to the error is that I am creating an ArrayList object for _sets to refer to. This is critical because otherwise _sets is null, which means it doesn't refer to any valid object, which then causes the NullPointerException which you saw.

Double Values are not passing from one activity to another

I am trying to pass 3 calculated values from Activity 1 to activity 2. Every time I see the result as 0.0 in Activity 2. Please help.
Activity 1:
submit = (Button)findViewById(R.id.submit);
try {
submit.setOnClickListener(new Button.OnClickListener() {
#Override
public void onClick
(View v) {
Intent i = new Intent(MainActivity.this, output.class);
Bundle b = new Bundle();
b.putDouble("gyrerror", gyroerr);
b.putDouble("compasserror", comperr);
b.putDouble("deviation", dev);
i.putExtras(b);
startActivity(i);
}
});
}
catch( Exception e)
{
}
}
Activity 2:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.output);
TextView gyroerror = (TextView) findViewById(R.id.gyerr1);
TextView comperror = (TextView) findViewById(R.id.comperr1);
TextView deviation = (TextView) findViewById(R.id.dev1);
Bundle b = getIntent().getExtras();
double gyroerr =b.getDouble("gyroerr");
double comperr= b.getDouble("comperr");
double dev = b.getDouble("dev");
gyroerror.setText(Double.toString(gyroerr));
comperror.setText(Double.toString(comperr));
deviation.setText(Double.toString(dev));
}}
Stack trace:
02-24 09:38:49.775 997-997/com.example.supriyaraman.sample I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
02-24 09:38:49.785 997-997/com.example.supriyaraman.sample W/dalvikvm﹕ VFY: unable to resolve virtual method 11349: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
02-24 09:38:49.785 997-997/com.example.supriyaraman.sample I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
02-24 09:38:49.785 997-997/com.example.supriyaraman.sample W/dalvikvm﹕ VFY: unable to resolve virtual method 11355: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
02-24 09:38:49.805 997-997/com.example.supriyaraman.sample I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
02-24 09:38:49.805 997-997/com.example.supriyaraman.sample W/dalvikvm﹕ VFY: unable to resolve virtual method 9043: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
02-24 09:38:49.825 997-997/com.example.supriyaraman.sample I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
02-24 09:38:49.825 997-997/com.example.supriyaraman.sample W/dalvikvm﹕ VFY: unable to resolve virtual method 366: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
02-24 09:38:49.835 997-997/com.example.supriyaraman.sample I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
02-24 09:38:49.835 997-997/com.example.supriyaraman.sample W/dalvikvm﹕ VFY: unable to resolve virtual method 388: Landroid/content/res/TypedArray;.getType (I)I
02-24 09:38:50.015 997-997/com.example.supriyaraman.sample I/dalvikvm-heap﹕ Grow heap (frag case) to 4.427MB for 1127536-byte allocation
02-24 09:38:50.195 997-997/com.example.supriyaraman.sample I/dalvikvm-heap﹕ Grow heap (frag case) to 6.846MB for 2536936-byte allocation
02-24 09:38:55.756 997-997/com.example.supriyaraman.sample W/EGL_emulation﹕ eglSurfaceAttrib not implemented
02-24 09:38:56.015 997-997/com.example.supriyaraman.sample I/Choreographer﹕ Skipped 293 frames! The application may be doing too much work on its main thread.
02-24 09:41:38.537 997-997/com.example.supriyaraman.sample W/EGL_emulation﹕ eglSurfaceAttrib not implemented
You are using different keys to put and to get your values:
Put:
b.putDouble("gyrerror", gyroerr);
Get:
double gyroerr =b.getDouble("gyroerr");
To avoid that, I recomend you to define static values for keys and use it to put/get extras, so typos won't affect:
final static String GYRO_ERROR = "gyroerr";
...
b.putDouble(GYRO_ERROR, gyroerr);
...
double gyroerr =b.getDouble(GYRO_ERROR);
Put everything in your intent. Like:
Intent i = new Intent(this, NextActivity.class);
i.put("gyrerror", gyroerr);
i.put("compasserror", comperr);
i.put("deviation", dev);
startActivity(i);
Then in your next class you have:
Bundle b = this.getIntent().getExtras();
This gets the extras from your INTENT not bundle. So you need to say:
double d = b.getDouble("gyrerror");
This should work.

Categories

Resources