Page 5 of 6

Re: JAVA Learning Group

Posted: 27 Sep 2017, 14:13
by Bearbear76
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jasoftware.justanyonecomp/com.jasoftware.justanyonecomp.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaPlayer.start()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2321)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2381)
at android.app.ActivityThread.access$800(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5260)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:678)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaPlayer.start()' on a null object reference
at com.jasoftware.justanyonecomp.MainActivity.initializeLogic(MainActivity.java:82)
at com.jasoftware.justanyonecomp.MainActivity.onCreate(MainActivity.java:47)
at android.app.Activity.performCreate(Activity.java:5975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2274)
... 10 more
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaPlayer.start()' on a null object reference
at com.jasoftware.justanyonecomp.MainActivity.initializeLogic(MainActivity.java:82)
at com.jasoftware.justanyonecomp.MainActivity.onCreate(MainActivity.java:47)
at android.app.Activity.performCreate(Activity.java:5975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2274)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2381)
at android.app.ActivityThread.access$800(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5260)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:678)

Re: JAVA Learning Group

Posted: 27 Sep 2017, 14:15
by JustAnyone
Where is my rope at?

Re: JAVA Learning Group

Posted: 27 Sep 2017, 14:15
by Bearbear76
Maybe ask lobby

Re: JAVA Learning Group

Posted: 27 Sep 2017, 14:20
by JustAnyone
https://drive.google.com/file/d/0B32tv5 ... p=drivesdk
Last try. If this Doesn't work. Wait for 1.2

Re: JAVA Learning Group

Posted: 27 Sep 2017, 14:47
by JustAnyone
Does this work?

Re: JAVA Learning Group

Posted: 27 Sep 2017, 14:50
by Bearbear76
Yeah

Re: JAVA Learning Group

Posted: 27 Sep 2017, 15:50
by Lobby
NullPointerExceptions are the main reason for crashes in Java programs :java :bb

Re: JAVA Learning Group

Posted: 30 Sep 2017, 11:57
by JustAnyone
Version and device language checker.
Version and device language checker.

Re: JAVA Learning Group

Posted: 30 Sep 2017, 12:33
by Ahmad Nur Aizat
The copyright info format is supposed to be like this:

©JustAnyone 2017

No need to put long words like Copyright, cause you already had the symbol

Re: JAVA Learning Group

Posted: 30 Sep 2017, 13:01
by JustAnyone
Ahmad Nur Aizat wrote:
30 Sep 2017, 12:33
The copyright info format is supposed to be like this:

©JustAnyone 2017

No need to put long words like Copyright, cause you already had the symbol
Ok.
:bf

Re: JAVA Learning Group

Posted: 30 Sep 2017, 14:15
by JustAnyone
I need a bug spray.

Re: JAVA Learning Group

Posted: 30 Sep 2017, 16:25
by Ahmad Nur Aizat
Most of grocery stores have aerosols....

But I recommend you to buy the "child-friendly" ones

;P

Re: JAVA Learning Group

Posted: 30 Sep 2017, 18:30
by JustAnyone
Permission to call is only used by Virtual JustAnyone if you type "kill kamile" or "kill auguste" it will dial their friend's number. (Gonna change to 911(maybe(idk))).

Re: JAVA Learning Group

Posted: 30 Sep 2017, 19:07
by CommanderABab
DO NOT change them to 911. That is a lawbreaking offense!

Re: JAVA Learning Group

Posted: 30 Sep 2017, 22:01
by JustAnyone
Actually I think I have a better idea. Make them listen to music for 10 minutes on loop!

Re: JAVA Learning Group

Posted: 06 Oct 2017, 15:29
by Lobby
In case you've ever wondered how a name generator might work:

Code: Select all

import java.util.Random;

/**
 * Created by Lobby on 10.04.2015.
 */
public class NameGenerator {

    private final static char[] CHARS = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

    private final static boolean[] IS_VOCAL = {true, false, false, false, true, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false};

    private final static float[] P = {0.08f, 0.015f, 0.027f, 0.043f, 0.127f, 0.022f, 0.02f, 0.06f, 0.07f, 0.015f, 0.077f, 0.04f,
            0.024f, 0.067f, 0.075f, 0.019f, 0.0009f, 0.06f, 0.063f, 0.09f, 0.027f, 0.098f, 0.024f, 0.015f, 0.02f, 0.00074f};

    private final static float[] FIRST_P = {0.11f, 0.047f, 0.035f, 0.027f, 0.02f, 0.038f, 0.02f, 0.07f, 0.06f, 0.006f, 0.006f, 0.027f, 0.044f,
            0.024f, 0.063f, 0.025f, 0.0017f, 0.017f, 0.078f, 0.17f, 0.015f, 0.006f, 0.068f, 0.0001f, 0.016f, 0.003f};

    private Random rnd;

    public NameGenerator() {
        rnd = new Random();
    }

    public String generate() {
        int length = rnd.nextInt(5) + 3;

        int index = getProbIndex(i -> FIRST_P[i], CHARS.length);

        StringBuilder builder = new StringBuilder(length);
        builder.append(Character.toUpperCase(CHARS[index]));

        final int[] lastIndex = new int[] {index};
        final int[] lastLastIndex = new int[] {index};

        for (int i = 1; i < length; i++) {
            lastLastIndex[0] = lastIndex[0];
            lastIndex[0] = index;
            index = getProbIndex(idx -> {
                    if ((IS_VOCAL[idx] != IS_VOCAL[lastIndex[0]] || IS_VOCAL[idx]) &&
                            lastLastIndex[0] != idx) {
                        return P[idx];
                    }
                    return 0;
            }, CHARS.length);
            builder.append(CHARS[index]);
        }

        return builder.toString();
    }

    private int getProbIndex(ProbFilter filter, int length) {
        float sum = 0.f;

        for (int i = 0; i < length; i++) {
            sum += filter.prob(i);
        }

        float v = rnd.nextFloat() * sum;

        sum = 0.f;
        for (int i = 0; i < length; i++) {
            sum += filter.prob(i);
            if (sum > v) return i;
        }

        return length - 1;
    }

    interface ProbFilter {
        float prob(int i);
    }

    public static void main(String[] args) {
        NameGenerator nameGenerator = new NameGenerator();
        System.out.println(nameGenerator.generate());
    }
}
It heavily relays on probabilities for specific word sequences in English language.

Re: JAVA Learning Group

Posted: 06 Oct 2017, 17:28
by JustAnyone
How do I make app save files to external storage from assets folder?

Re: JAVA Learning Group

Posted: 07 Oct 2017, 17:42
by Lobby
Create an InputStream from the file you want to write out and write bytes out manually. See here. The Android API doesn't help you much here.

Re: JAVA Learning Group

Posted: 27 Nov 2017, 01:11
by JustAnyone
Finally found this topic.
I present you "Plugin Creator"!
*Poof*
I will help you create simple plugins without any knowledge.
NOTE: This is still testing version!
1.0
pluginmaker.apk
Plugin Maker 1.0
(2.36 MiB) Downloaded 86 times

Re: JAVA Learning Group

Posted: 27 Nov 2017, 01:55
by Josh
JustAnyone wrote:
27 Nov 2017, 01:11
Finally found this topic.
I present you "Plugin Creator"!
*Poof*
I will help you create simple plugins without any knowledge.
NOTE: This is still testing version!
1.0
pluginmaker.apk
That's really cool, I hope you can keep improving the app!