Click here to Skip to main content
14,694,402 members
Home » Discussions » Android
   

Android

 
QuestionEmotion Based Android app Pin
Member 1137002712-Jan-15 10:26
MemberMember 1137002712-Jan-15 10:26 
SuggestionWhat kind of suggestions can you give to a beginner in android app developement? Pin
Tiffany_Summers10-Jan-15 14:30
MemberTiffany_Summers10-Jan-15 14:30 
AnswerRe: What kind of suggestions can you give to a beginner in android app developement? Pin
Kornfeld Eliyahu Peter10-Jan-15 21:23
mveKornfeld Eliyahu Peter10-Jan-15 21:23 
GeneralRe: What kind of suggestions can you give to a beginner in android app developement? Pin
Member 1036419227-Jan-15 2:05
MemberMember 1036419227-Jan-15 2:05 
GeneralRe: What kind of suggestions can you give to a beginner in android app developement? Pin
Richard MacCutchan10-Jan-15 22:42
mveRichard MacCutchan10-Jan-15 22:42 
QuestionMp3 Cutter Android Coding Pin
Ranjithkumar .8-Jan-15 22:44
MemberRanjithkumar .8-Jan-15 22:44 
AnswerRe: Mp3 Cutter Android Coding Pin
Richard MacCutchan9-Jan-15 5:05
mveRichard MacCutchan9-Jan-15 5:05 
QuestionAndroid crash when app is high score menu opened Pin
Member 113605017-Jan-15 21:40
MemberMember 113605017-Jan-15 21:40 
He
I am new to android programming. I tried to execute a app from one of the tutorials and it is showing runtime error. If it runs highscores menu. Application closed. Below are the error messages from logcat and the activity file. Appreciate your help. Thanks in advance.

Error

12-15 03:49:51.124: I/HighScores(1115): getScores() called
12-15 03:49:51.154: I/HighScores(1115): getScores() no scores found
12-15 03:49:51.354: I/Reversi, RevHSCustAd getView called(1115): position = 0
12-15 03:49:51.444: I/Reversi, RevHSCustAd getView called(1115): position = 0
12-15 03:49:51.454: D/AndroidRuntime(1115): Shutting down VM
12-15 03:49:51.454: W/dalvikvm(1115): threadid=1: thread exiting with uncaught exception (group=0xb2a40ba8)
12-15 03:49:51.594: D/dalvikvm(1115): GC_FOR_ALLOC freed 447K, 11% free 4353K/4880K, paused 89ms, total 100ms
12-15 03:49:51.714: E/AndroidRuntime(1115): FATAL EXCEPTION: main
12-15 03:49:51.714: E/AndroidRuntime(1115): Process: uk.co.flumeland.reversi, PID: 1115
12-15 03:49:51.714: E/AndroidRuntime(1115): java.lang.NullPointerException
12-15 03:49:51.714: E/AndroidRuntime(1115): at uk.co.flumeland.reversi.RevHighScoreAdapter.getView(RevHighScoreAdapter.java:68)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.widget.AbsListView.obtainView(AbsListView.java:2263)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.widget.ListView.measureHeightOfChildren(ListView.java:1263)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.widget.ListView.onMeasure(ListView.java:1175)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.View.measure(View.java:16497)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.View.measure(View.java:16497)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.View.measure(View.java:16497)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
12-15 03:49:51.714: E/AndroidRuntime(1115): at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.View.measure(View.java:16497)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
12-15 03:49:51.714: E/AndroidRuntime(1115): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.View.measure(View.java:16497)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.Choreographer.doFrame(Choreographer.java:544)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.os.Handler.handleCallback(Handler.java:733)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.os.Handler.dispatchMessage(Handler.java:95)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.os.Looper.loop(Looper.java:136)
12-15 03:49:51.714: E/AndroidRuntime(1115): at android.app.ActivityThread.main(ActivityThread.java:5017)
12-15 03:49:51.714: E/AndroidRuntime(1115): at java.lang.reflect.Method.invokeNative(Native Method)
12-15 03:49:51.714: E/AndroidRuntime(1115): at java.lang.reflect.Method.invoke(Method.java:515)
12-15 03:49:51.714: E/AndroidRuntime(1115): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
12-15 03:49:51.714: E/AndroidRuntime(1115): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
12-15 03:49:51.714: E/AndroidRuntime(1115): at dalvik.system.NativeStart.main(Native Method)
12-15 03:49:51.864: W/CursorWrapperInner(1115): Cursor finalized without prior close()
12-15 03:49:54.184: I/Process(1115): Sending signal. PID: 1115 SIG: 9

RevHighScoreAdapter.java

package uk.co.flumeland.reversi;

import java.util.ArrayList;
import java.lang.String;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class RevHighScoreAdapter extends ArrayAdapter {

    private Score[] scores;
    private Context context;

// Constructor
public RevHighScoreAdapter(Context context, Score[] score){
        super(context, 0);
        scores = score;
        this.context = context;
        }


    @Override
    public int getCount() {
        // length of list
        return scores.length;
    }

    @Override
    public Object getItem(int position) {
        // length of list
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        Log.i("Reversi, RevHSCustAd getView called", "position = " + position );

        if (row == null) {
            LayoutInflater inflater = ((Activity) context).getLayoutInflater();
            row = inflater.inflate(R.layout.high_scores_listview_row, parent, false);
        }
        TextView nameTV = (TextView) row.findViewById(R.id.hs_player_name_lv);
        ImageView photoIV = (ImageView) row.findViewById(R.id.hs_player_image_lv);
        TextView scoreTV = (TextView) row.findViewById(R.id.hs_score_lv);
        Log.i("Reversi, RevHSCustAd getView called", "position = " + position );

        //if (scores[position].getPhotolink() != null) {
            //photoIV.setImageURI(Uri.parse(scores[position].getPhotolink()));
        //} else {
            //photoIV.setImageResource(R.drawable.social_add_person);
        //}
            nameTV.setText(scores[position].getName());
            Log.i("Reversi, RevHSCustAd getView called", "position = " + position );
            scoreTV.setText(String.valueOf(scores[position].getScore()));

        return row;
    }
}


HighScores.java

package uk.co.flumeland.reversi;

import java.util.ArrayList;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class HighScores extends Activity {

    private Score[] score = new Score[10];
    private ListView scoreList;
    private ContentResolver cr;
    private RevHighScoreAdapter rHSad;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_high_scores_screen);
        TextView title = (TextView) findViewById(R.id.title_textview);
        scoreList = (ListView) findViewById(R.id.high_score_list);
        Typeface tf = Typeface.createFromAsset(getAssets(),
                "fonts/tattoowoo_naughty-nights/Naughty Nights.ttf");
        title.setTypeface(tf);
        getScores();
        loadScores();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu, menu);
        return true;
    }

    /**
     * Loads scores into the score ArrayList
     */
    public void getScores() {
        Log.i("HighScores", "getScores() called");
        cr = getContentResolver();
        Cursor c = cr.query(HighScoresData.CONTENT_URI, null, null, null,
                HighScoresData.KEY_SCORE + " DESC");
        // looping through all rows and adding to list
        int numScores = c.getCount();
        int i = 0;
        if (c != null && c.getCount() > 0) {
            c.moveToFirst();
            do {
                Log.i("HighScores", "getScores() = "
                                + c.getString(HighScoresData.NAME_COLUMN) + " " 
                                + c.getString(HighScoresData.PHOTO_COLUMN) + " "
                                + c.getInt(HighScoresData.SCORE_COLUMN) + " " + i);
                score[i] = new Score(c.getString(HighScoresData.NAME_COLUMN),
                        c.getString(HighScoresData.PHOTO_COLUMN),
                        c.getInt(HighScoresData.SCORE_COLUMN));
                //score[i] = sc;
                i++;
            } while (c.moveToNext() && i < 10);
        } else {
            Log.i("HighScores", "getScores() no scores found");
        }
    }

    private void loadScores() {
    rHSad = new RevHighScoreAdapter(this, score);
    // Set the Adapter to GridView
    scoreList.setAdapter(rHSad);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.action_settings:
            startActivity(new Intent(this, Settings.class));
            return true;
        case R.id.action_how_to:
            startActivity(new Intent(this, HowTo.class));
            return true;
        case R.id.action_high_scores:
            startActivity(new Intent(this, HighScores.class));
            return true;
        }
        return false;
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        finish();
    }

}

AnswerRe: Android crash when app is high score menu opened Pin
Richard MacCutchan8-Jan-15 0:00
mveRichard MacCutchan8-Jan-15 0:00 
GeneralRe: Android crash when app is high score menu opened Pin
Member 113605018-Jan-15 1:01
MemberMember 113605018-Jan-15 1:01 
GeneralRe: Android crash when app is high score menu opened Pin
Richard MacCutchan8-Jan-15 1:09
mveRichard MacCutchan8-Jan-15 1:09 
GeneralRe: Android crash when app is high score menu opened Pin
Member 113605018-Jan-15 1:12
MemberMember 113605018-Jan-15 1:12 
GeneralRe: Android crash when app is high score menu opened Pin
Richard MacCutchan8-Jan-15 1:36
mveRichard MacCutchan8-Jan-15 1:36 
GeneralRe: Android crash when app is high score menu opened Pin
Member 113605018-Jan-15 2:03
MemberMember 113605018-Jan-15 2:03 
GeneralRe: Android crash when app is high score menu opened Pin
Gonzoox5-Mar-15 5:38
MemberGonzoox5-Mar-15 5:38 
AnswerRe: Android crash when app is high score menu opened Pin
David Crow8-Jan-15 4:34
MemberDavid Crow8-Jan-15 4:34 
QuestionAndroid USB Mode Pin
Sarita S7-Jan-15 1:21
MemberSarita S7-Jan-15 1:21 
Questionksoap2: error call webservice Pin
nvpopovich2-Jan-15 0:20
Membernvpopovich2-Jan-15 0:20 
QuestionAndroid USB Mode Pin
Sarita S26-Dec-14 0:21
MemberSarita S26-Dec-14 0:21 
AnswerRe: Android USB Mode Pin
Richard MacCutchan26-Dec-14 23:29
mveRichard MacCutchan26-Dec-14 23:29 
AnswerRe: Android USB Mode Pin
Sarita S31-Dec-14 0:50
MemberSarita S31-Dec-14 0:50 
AnswerRe: Android USB Mode Pin
Member 117320901-Jun-15 1:09
MemberMember 117320901-Jun-15 1:09 
QuestionAndroid application Pin
APURBA RAM24-Dec-14 4:00
MemberAPURBA RAM24-Dec-14 4:00 
JokeRe: Android application Pin
APURBA RAM24-Dec-14 4:02
MemberAPURBA RAM24-Dec-14 4:02 
AnswerRe: Android application Pin
Peter Leow24-Dec-14 4:55
professionalPeter Leow24-Dec-14 4:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.