So I'm trying to something fairly simple. Have a very basic screen that has 4 blocks (Bitmaps 0-3 in my code) which are different colors that cycle from the bottom to the top of the screen. When the bitmap reaches the top (goes offscreen), I want it to change to a different bitmap randomly and then restart itself from the beginning. I'll attach my GameView class below (which an instance of is sent into the main layout).
PHP:
public class GameView extends View {
private static final int Y_VELOCITY = 8;
int x=0,y=0; //Enemy positions
int p=0; //onDraw Counter
Bitmap a,b,c,d;
Bitmap[] bitmapArray = {a,b,c,d};//0,1,2,3
Bitmap currentBitmap;
private Canvas canvas;
public GameView(Context context) {
super(context);
loadResources(currentBitmap);
}
private void loadResources(Bitmap mBitmap) {
bitmapArray[0] = BitmapFactory.decodeResource(getResources(), R.drawable.box_one);
bitmapArray[1] = BitmapFactory.decodeResource(getResources(), R.drawable.box_two);
bitmapArray[2] = BitmapFactory.decodeResource(getResources(), R.drawable.box_three);
bitmapArray[3] = BitmapFactory.decodeResource(getResources(), R.drawable.box_four);
mBitmap = bitmapArray[0];
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//Draw canvas to put paint on
Rect canvasRect = new Rect();
Paint canvasBG = new Paint();
canvasBG.setColor(Color.WHITE);
canvasRect.set(0, 0, canvas.getWidth(), canvas.getHeight());
canvas.drawRect(canvasRect, canvasBG);
//Draw bitmaps- First make vertical loop with 1 block
if(y < -100) {
currentBitmap= bitmapArray[randomNumGenerator(3,0)];
p++; //Counter to initialize first enemy OFFSCREEN, (see else rule)
Thread startTimer = new Thread();
try { //If restarting, sleep for .5 seconds then respawn in random X w/ Y offscreen
y=canvas.getHeight()+50;
x= randomNumGenerator(canvas.getWidth(), 0); //Generate next X in random position as respawns
startTimer.sleep(randomNumGenerator(5000,100)); //Sleeps for random time between .1-5s
} catch (InterruptedException e) {
e.printStackTrace();
}
} else { //If first time enemy spawns, start him offscreen (-500) else, shoot him up screen
if(p==0) {
y=-500;
} else {
y-=Y_VELOCITY;
}
}
canvas.drawBitmap(currentBitmap, x, y, null);
invalidate();
}
private static int randomNumGenerator(int max, int min) {
//Set min = 0 for nextInt()
Random randomNum = new Random();
int randomNumVal = randomNum.nextInt(max - min) + min ;
return randomNumVal;
}
}
I receive no errors in eclipse when running this but when I port it to my phone it closes the the error I get is a nullpointerexception [logcat below] for cannot draw bitmap (currentBitmap). If I change currentBitmap in canvas.drawBitmap section to say bitmapArray[2] it works perfectly fine but obviously the bitmaps wont cycle randomly then. If I initialize currentBitmap in my ondraw it won't cycle as well- it just keeps resetting to whatever I have my currentBitmap set to everytime it re-draws itself... Where am I going wrong here?
PHP:
11-13 23:39:11.189: E/AndroidRuntime(17736): FATAL EXCEPTION: main
11-13 23:39:11.189: E/AndroidRuntime(17736): Process: com.twigmandesigns.veritcalautoscrollertest, PID: 17736
11-13 23:39:11.189: E/AndroidRuntime(17736): java.lang.NullPointerException
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1083)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:816)
11-13 23:39:11.189: E/AndroidRuntime(17736): at com.twigmandesigns.veritcalautoscrollertest.GameView.onDraw(GameView.java:74)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.draw(View.java:15508)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.getDisplayList(View.java:14402)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.getDisplayList(View.java:14444)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.draw(View.java:15222)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.ViewGroup.drawChild(ViewGroup.java:3340)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3176)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.getDisplayList(View.java:14397)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.getDisplayList(View.java:14444)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.draw(View.java:15222)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.ViewGroup.drawChild(ViewGroup.java:3340)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3176)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.draw(View.java:15511)
11-13 23:39:11.189: E/AndroidRuntime(17736): at com.android.internal.widget.ActionBarOverlayLayout.draw(ActionBarOverlayLayout.java:468)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.getDisplayList(View.java:14402)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.getDisplayList(View.java:14444)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.draw(View.java:15222)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.ViewGroup.drawChild(ViewGroup.java:3340)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3176)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.draw(View.java:15511)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.widget.FrameLayout.draw(FrameLayout.java:472)
11-13 23:39:11.189: E/AndroidRuntime(17736): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2623)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.getDisplayList(View.java:14402)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.View.getDisplayList(View.java:14444)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1597)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1469)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2800)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2666)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2234)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1267)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6638)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:813)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.Choreographer.doCallbacks(Choreographer.java:613)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.Choreographer.doFrame(Choreographer.java:583)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:799)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.os.Handler.handleCallback(Handler.java:733)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.os.Handler.dispatchMessage(Handler.java:95)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.os.Looper.loop(Looper.java:146)
11-13 23:39:11.189: E/AndroidRuntime(17736): at android.app.ActivityThread.main(ActivityThread.java:5635)
11-13 23:39:11.189: E/AndroidRuntime(17736): at java.lang.reflect.Method.invokeNative(Native Method)
11-13 23:39:11.189: E/AndroidRuntime(17736): at java.lang.reflect.Method.invoke(Method.java:515)
11-13 23:39:11.189: E/AndroidRuntime(17736): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
11-13 23:39:11.189: E/AndroidRuntime(17736): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
11-13 23:39:11.189: E/AndroidRuntime(17736): at dalvik.system.NativeStart.main(Native Method)
Check 4'th parameter of drawBitmap(), Paint object can not be null. Create new one and it will fix the problem.
Related
Im trying to start a simple app and i need to display on a SurfaceView the preview of the cam as soon as the App start.
i added the permission to the manifest:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
and my code:
Code:
import android.content.Context;
import android.hardware.Camera;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class MainActivity extends SurfaceView implements SurfaceHolder.Callback{
SurfaceView mSurfaceView;
private SurfaceHolder mHolder;
public Camera camera = null;
public MainActivity(Context context) {
super(context);
mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
mHolder = mSurfaceView.getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
[user=439709]@override[/user]
public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open();
try{
camera.setPreviewDisplay(mHolder);
} catch(Exception e){
}
}
[user=439709]@override[/user]
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Camera.Parameters params = camera.getParameters();
params.setPreviewSize(width,height);
camera.setParameters(params);
camera.startPreview();
}
[user=439709]@override[/user]
public void surfaceDestroyed(SurfaceHolder holder) {
camera.stopPreview();
camera = null;
}
}
Ive looked for many tutorial and all technically do the same or smiliart stuff. But the app crashes. I cant find a solution
LogCat
Code:
06-01 12:39:12.456 616-841/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.droidcam/.MainActivity bnds=[240,408][240,408]} from pid 861
06-01 12:39:12.596 616-841/system_process D/dalvikvm: GC_FOR_ALLOC freed 1352K, 16% free 11518K/13560K, paused 112ms, total 118ms
06-01 12:39:12.636 2744-2744/? D/dalvikvm: Late-enabling CheckJNI
06-01 12:39:12.646 616-881/system_process I/ActivityManager: Start proc com.example.droidcam for activity com.example.droidcam/.MainActivity: pid=2744 uid=10019 gids={50019, 1006, 1028}
06-01 12:39:12.746 2744-2744/com.example.droidcam E/Trace: error opening trace file: No such file or directory (2)
06-01 12:39:12.826 2744-2744/com.example.droidcam D/dalvikvm: newInstance failed: no <init>()
06-01 12:39:12.836 2744-2744/com.example.droidcam D/AndroidRuntime: Shutting down VM
06-01 12:39:12.836 2744-2744/com.example.droidcam W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x2b5d9930)
06-01 12:39:12.836 2744-2744/com.example.droidcam E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.droidcam/com.example.droidcam.MainActivity}: java.lang.InstantiationException: can't instantiate class com.example.droidcam.MainActivity; no empty constructor
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2223)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2357)
at android.app.ActivityThread.access$600(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5226)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.InstantiationException: can't instantiate class com.example.droidcam.MainActivity; no empty constructor
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2214)
... 11 more
06-01 12:39:12.836 616-1341/system_process W/ActivityManager: Force finishing activity com.example.droidcam/.MainActivity
06-01 12:39:12.986 616-650/system_process D/dalvikvm: GC_FOR_ALLOC freed 1696K, 24% free 10472K/13772K, paused 76ms, total 77ms
06-01 12:39:13.387 616-647/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{2bd8aff0 u0 com.example.droidcam/.MainActivity}
06-01 12:39:18.952 2744-2744/? I/Process: Sending signal. PID: 2744 SIG: 9
06-01 12:39:18.952 616-943/system_process I/ActivityManager: Process com.example.droidcam (pid 2744) has died.
06-01 12:39:19.002 616-616/system_process W/InputMethodManagerService: Window already focused, ignoring focus gain of: [email protected] attribute=null, token = [email protected]
Please put your code into code tags.
EDIT: Thanks.
and Post/check logcats.
just saying it crashes is too vague.
out of ideas said:
and Post/check logcats.
just saying it crashes is too vague.
Click to expand...
Click to collapse
On Eclipse i know how to show the windows of the LogCat, but cant really find it here on Android Studio.
Im a bit newby about this sorry, coming from PHP using just Notepad.
Guess i found it, added log cat
I saw some tutorial like this, im not sure why it doesnt start.
Is it for te onCreate method missing? but i saw that for other works anyway like this
Btw i've also triyed an other way, but stills give me errors. i could upload that one too, different logcat.
Hope one of the two could be solved
Code:
import android.app.Activity;
import android.hardware.Camera;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import java.io.IOException;
public class MainActivity extends Activity implements SurfaceHolder.Callback{
/* VARIABILI PRIVATE */
private SurfaceView mSurfaceView;
private SurfaceHolder mSurfaceHolder;
private Camera mCamera;
/** Called when the activity is first created. */
[user=439709]@override[/user]
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSurfaceView = (SurfaceView)findViewById(R.id.surfaceView);
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
[user=439709]@override[/user]
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
Camera.Parameters params = mCamera.getParameters();
params.setPreviewSize(arg2, arg3);
mCamera.setParameters(params);
try {
//lancio la preview
mCamera.setPreviewDisplay(arg0);
mCamera.startPreview();
} catch (IOException e) {
//gestione errore
}
}
[user=439709]@override[/user]
public void surfaceCreated(SurfaceHolder holder) {
mCamera = Camera.open();
}
[user=439709]@override[/user]
public void surfaceDestroyed(SurfaceHolder holder) {
mCamera.stopPreview();
mCamera.release();
}
logcat
Code:
06-01 13:32:31.187 616-661/system_process I/ActivityManager: Start proc com.android.vending for service com.android.vending/com.google.android.finsky.services.ContentSyncService: pid=25552 uid=10005 gids={50005, 3003, 1015, 1028}
06-01 13:32:31.227 25552-25552/com.android.vending E/Trace: error opening trace file: No such file or directory (2)
06-01 13:32:31.387 616-841/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.droidcam/.MainActivity bnds=[240,408][240,408]} from pid 861
06-01 13:32:31.437 25566-25566/? D/dalvikvm: Late-enabling CheckJNI
06-01 13:32:31.447 616-1341/system_process I/ActivityManager: Start proc com.example.droidcam for activity com.example.droidcam/.MainActivity: pid=25566 uid=10019 gids={50019, 1006, 1028}
06-01 13:32:31.607 25566-25566/com.example.droidcam E/Trace: error opening trace file: No such file or directory (2)
06-01 13:32:31.787 25552-25552/com.android.vending D/Finsky: [1] FinskyApp.onCreate: Initializing network with DFE https://android.clients.google.com/fdfe/
06-01 13:32:31.987 25552-25552/com.android.vending D/Finsky: [1] DailyHygiene.goMakeHygieneIfDirty: No need to run daily hygiene.
06-01 13:32:32.037 25552-25552/com.android.vending W/Settings: Setting download_manager_max_bytes_over_mobile has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
06-01 13:32:32.037 25552-25552/com.android.vending W/Settings: Setting download_manager_recommended_max_bytes_over_mobile has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
06-01 13:32:32.178 616-881/system_process D/dalvikvm: GC_FOR_ALLOC freed 656K, 26% free 11321K/15124K, paused 82ms, total 86ms
06-01 13:32:32.238 25566-25566/com.example.droidcam D/libEGL: loaded /system/lib/egl/libEGL_adreno200.so
06-01 13:32:32.258 25566-25566/com.example.droidcam D/libEGL: loaded /system/lib/egl/libGLESv1_CM_adreno200.so
06-01 13:32:32.258 25566-25566/com.example.droidcam D/libEGL: loaded /system/lib/egl/libGLESv2_adreno200.so
06-01 13:32:32.268 25566-25566/com.example.droidcam I/Adreno200-EGL: <qeglDrvAPI_eglInitialize:294>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_JB.04.01.01.00.036_msm8960_JB_CL2644550_release_AU (CL2644550)
Build Date: 07/31/12 Tue
Local Branch:
Remote Branch: quic/master
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_JB.04.01.01.00.036 + NOTHING
06-01 13:32:32.318 25566-25566/com.example.droidcam D/OpenGLRenderer: Enabling debug mode 0
06-01 13:32:32.348 256-515/? I/AwesomePlayer: setDataSource_l(URL suppressed)
06-01 13:32:32.378 256-25622/? D/MediaExtractor: returning default extractor
06-01 13:32:32.388 256-515/? I/AwesomePlayer: setDataSource_l(URL suppressed)
06-01 13:32:32.408 256-25626/? D/MediaExtractor: returning default extractor
06-01 13:32:32.408 256-515/? I/CameraClient: Opening camera 0
06-01 13:32:32.408 256-515/? W/ServiceManager: Permission failure: com.sonyericsson.permission.CAMERA_EXTENDED from uid=10019 pid=25566
06-01 13:32:32.438 256-25630/? I/caladbolg: 3348999538 cald_camctrl.c (6713) 25630 P [SVR] -945967758 + Cald_CamCtrl_PowerUp
06-01 13:32:32.438 256-25630/? I/caladbolg: 3348999630 cald_camctrl.c (7484) 25630 P [SVR] -945967666 + Cald_CamCtrl_FSM_Func_PowerUp
06-01 13:32:32.438 256-25630/? I/caladbolg: 3349003170 cald_hal_qct.c (2789) 25630 P [HAL] -945964126 + Cald_Hal_Qct_If_PowerUp
06-01 13:32:32.438 256-25630/? I/caladbolg: 3349003323 cald_hal_qct.c (2847) 25630 P [HAL] -945963973 - Cald_Hal_Qct_If_PowerUp (0)
06-01 13:32:32.438 256-25630/? I/caladbolg: 3349004665 cald_camctrl.c (7563) 25630 P [SVR] -945962631 - Cald_CamCtrl_FSM_Func_PowerUp (0)
06-01 13:32:32.438 256-25630/? I/caladbolg: 3349004726 cald_camctrl.c (6720) 25630 P [SVR] -945962570 - Cald_CamCtrl_PowerUp (0)
06-01 13:32:32.448 256-25630/? E/caladbolg: 3349014431 cald_camctrl.c (11888) 25630 E [SVR] PreviewSize Invalid param: value[402x527]
06-01 13:32:32.458 25566-25566/com.example.droidcam D/AndroidRuntime: Shutting down VM
06-01 13:32:32.458 25566-25566/com.example.droidcam W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x2b5d9930)
06-01 13:32:32.488 25566-25566/com.example.droidcam E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Native Method)
at android.hardware.Camera.setParameters(Camera.java:1496)
at com.example.droidcam.MainActivity.surfaceChanged(MainActivity.java:41)
at android.view.SurfaceView.updateWindow(SurfaceView.java:580)
at android.view.SurfaceView.access$000(SurfaceView.java:86)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:174)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:680)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1842)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:532)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5226)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
06-01 13:32:32.498 616-943/system_process W/ActivityManager: Force finishing activity com.example.droidcam/.MainActivity
06-01 13:32:32.688 25552-25552/com.android.vending D/Finsky: [1] 2.run: Loaded library for account: [i1YaFxIWaZrcOQ26zxNX5K0RvvY]
06-01 13:32:32.688 25552-25552/com.android.vending D/Finsky: [1] 2.run: Finished loading 1 libraries.
06-01 13:32:32.908 25552-25552/com.android.vending D/Finsky: [1] 5.onFinished: Installation state replication succeeded.
06-01 13:32:33.018 616-647/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{2b946870 u0 com.example.droidcam/.MainActivity}
In Android you normally do not use the constructor of an Activity for anything.
Use the onCreate method instead.
EDIT: The log says that the constructor must be empty.
nikwen said:
In Android you normally do not use the constructor of an Activity for anything.
Use the onCreate method instead.
EDIT: The log says that the constructor must be empty.
Click to expand...
Click to collapse
I thought about that (even if i saw video tutorial doing it) so i tried wht onCreate method and now it seams to give problem with the setParameters?
Ive uploaded the new code and logcats before
Ah. Check this: http://stackoverflow.com/questions/3890381/camera-setparameters-failed-in-android
nikwen said:
Ah. Check this: http://stackoverflow.com/questions/3890381/camera-setparameters-failed-in-android
Click to expand...
Click to collapse
i tryed that at th beggin, and didnt work, in fact i tried it again and still give me the same error apparently
While I'm still learning myself, it looks like you are getting a failed camera permission. And then it tries to pass in an invalid parameter to the camera.
deniel said:
I/CameraClient: Opening camera 0
06-01 13:32:32.408 256-515/? W/ServiceManager: Permission failure: com.sonyericsson.permission.CAMERA_EXTENDED from uid=10019 pid=25566
06-01 13:32:32.448 256-25630/? E/caladbolg: 3349014431 cald_camctrl.c (11888) 25630 E [SVR] PreviewSize Invalid param: value[402x527]
[/CODE]
Click to expand...
Click to collapse
Sent from a Toasted Devil
netwokz said:
While I'm still learning myself, it looks like you are getting a failed camera permission. And then it tries to pass in an invalid parameter to the camera.
Sent from a Toasted Devil
Click to expand...
Click to collapse
But cant understand which one and how should i do. it ryed the 2 ways everybody does
What phone are you trying this on? Have you tried it in an emulator?
After getting home and I was able to try your second piece of code. It looks like it is a problem with <CODE>params.setPreviewSize(arg2, arg3);</CODE>, it doesn't like the width and height arguments. I found THIS(second answer). and after plugging it into your code it was working for me. If you like I can show you the modified code, altho its real easy to plug in.
netwokz said:
After getting home and I was able to try your second piece of code. It looks like it is a problem with <CODE>params.setPreviewSize(arg2, arg3);</CODE>, it doesn't like the width and height arguments. I found THIS(second answer). and after plugging it into your code it was working for me. If you like I can show you the modified code, altho its real easy to plug in.
Click to expand...
Click to collapse
i tryed his first example and finally i get his "distoted" image. When i'll have time ill try the rets thnk u very much
ill try this:
Code:
Camera.Size getBestPreviewSize(int width, int height, Camera.Parameters parameters) {
Camera.Size result=null;
float dr = Float.MAX_VALUE;
float ratio = (float)width/(float)height;
for (Camera.Size size : parameters.getSupportedPreviewSizes()) {
float r = (float)size.width/(float)size.height;
if( Math.abs(r - ratio) < dr && size.width <= width && size.height <= height ) {
dr = Math.abs(r - ratio);
result = size;
}
}
return result;
}
Code:
ublic void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// Now that the size is known, set up the camera parameters and begin
// the preview.
if (isPreviewRunning) {
mCamera.stopPreview();
}
Camera.Parameters parameters = mCamera.getParameters();
List<Size> sizes = parameters.getSupportedPreviewSizes();
Size optimalSize = getBestPreviewSize( w, h, parameters);
parameters.setPreviewSize(optimalSize.width, optimalSize.height);
mCamera.setParameters(parameters);
mCamera.startPreview();
isPreviewRunning =true;
}
im not sure abot the 3rd parameter of the getBestPreviewSize method which one is it. Like this is still distorted
Yeah, I could never fix the distortion back when I was trying my camera app. But I think I will tinker with it again. Keep this updated if you find anything, I will also.
Sent from a Toasted Devil
I have webservice setup http://168.187.121.70/WSJAWW/service.asmx
How can I call it?
I want to call it on buton click sendmessage
public void sendMessage(View view) {
// Do something in response to button
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
I have done this
Code:
package com.example.myfirstapp;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
private static final String SOAP_ACTION = "http://tempuri.org/GetAlbums";
private static final String METHOD_NAME = "GetAlbums";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://168.187.121.70/WSJAWW/service.asmx";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
public void sendMessage(View view) {
// Do something in response to button
/* Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);*/
try
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("ArtistId", "-1");
request.addProperty("StartId", "1");
request.addProperty("CatId", "1");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
Object result = (Object)envelope.getResponse();
Toast.makeText(this, result.toString(), Toast.LENGTH_LONG).show();
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
} catch (Exception e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.action_search:
// openSearch();
return true;
case R.id.action_settings:
// openSettings();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Click to expand...
Click to collapse
I get socket failed :EACCES (Permission denied)
krikor1 said:
I have done this
I get socket failed :EACCES (Permission denied)
Click to expand...
Click to collapse
I think you need to include <uses-permission android:name="android.permission.INTERNET"/> in your app's manifest file.
ndp_singe said:
I think you need to include <uses-permission android:name="android.permission.INTERNET"/> in your app's manifest file.
Click to expand...
Click to collapse
yes that did it, however when i debug i get stuck at [2013-09-19 18:38:02 - MYFirstApp] Attempting to connect debugger to 'com.example.myfirstapp' on port 8600
I wanna debug, coz i dont see anything i am doing system.out.println
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("ArtistId", "-1");
request.addProperty("StartId", "1");
request.addProperty("CatId", "1");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
System.out.println("krirkrirk");
Object result = (Object)envelope.getResponse();
Toast.makeText(this, result.toString(), Toast.LENGTH_LONG).show();
somewhere here its crashing imo
it crashes at androidHttpTransport.call(SOAP_ACTION, envelope);
dunno why.any help?
krikor1 said:
yes that did it, however when i debug i get stuck at [2013-09-19 18:38:02 - MYFirstApp] Attempting to connect debugger to 'com.example.myfirstapp' on port 8600
I wanna debug, coz i dont see anything i am doing system.out.println
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("ArtistId", "-1");
request.addProperty("StartId", "1");
request.addProperty("CatId", "1");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
System.out.println("krirkrirk");
Object result = (Object)envelope.getResponse();
Toast.makeText(this, result.toString(), Toast.LENGTH_LONG).show();
somewhere here its crashing imo
Click to expand...
Click to collapse
I think you cannot do System.out.println() on Android.
Use Log.d("myTag", "myMessage") instead.
nikwen said:
I think you cannot do System.out.println() on Android.
Use Log.d("myTag", "myMessage") instead.
Click to expand...
Click to collapse
I do that, i get my first app has to be stopped
Code:
09-19 18:47:05.798: E/AndroidRuntime(29848): FATAL EXCEPTION: main
09-19 18:47:05.798: E/AndroidRuntime(29848): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.view.View$1.onClick(View.java:3633)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.view.View.performClick(View.java:4240)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.os.Looper.loop(Looper.java:137)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:47:05.798: E/AndroidRuntime(29848): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:47:05.798: E/AndroidRuntime(29848): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:47:05.798: E/AndroidRuntime(29848): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:47:05.798: E/AndroidRuntime(29848): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:47:05.798: E/AndroidRuntime(29848): at dalvik.system.NativeStart.main(Native Method)
09-19 18:47:05.798: E/AndroidRuntime(29848): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:47:05.798: E/AndroidRuntime(29848): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:47:05.798: E/AndroidRuntime(29848): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.view.View$1.onClick(View.java:3628)
09-19 18:47:05.798: E/AndroidRuntime(29848): ... 11 more
09-19 18:47:05.798: E/AndroidRuntime(29848): Caused by: java.lang.NullPointerException: println needs a message
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.util.Log.println_native(Native Method)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.util.Log.d(Log.java:138)
09-19 18:47:05.798: E/AndroidRuntime(29848): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:47:05.798: E/AndroidRuntime(29848): ... 14 more
09-19 18:47:30.955: E/AndroidRuntime(30168): FATAL EXCEPTION: main
09-19 18:47:30.955: E/AndroidRuntime(30168): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.view.View$1.onClick(View.java:3633)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.view.View.performClick(View.java:4240)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.os.Looper.loop(Looper.java:137)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:47:30.955: E/AndroidRuntime(30168): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:47:30.955: E/AndroidRuntime(30168): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:47:30.955: E/AndroidRuntime(30168): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:47:30.955: E/AndroidRuntime(30168): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:47:30.955: E/AndroidRuntime(30168): at dalvik.system.NativeStart.main(Native Method)
09-19 18:47:30.955: E/AndroidRuntime(30168): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:47:30.955: E/AndroidRuntime(30168): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:47:30.955: E/AndroidRuntime(30168): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.view.View$1.onClick(View.java:3628)
09-19 18:47:30.955: E/AndroidRuntime(30168): ... 11 more
09-19 18:47:30.955: E/AndroidRuntime(30168): Caused by: java.lang.NullPointerException: println needs a message
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.util.Log.println_native(Native Method)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.util.Log.d(Log.java:138)
09-19 18:47:30.955: E/AndroidRuntime(30168): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:47:30.955: E/AndroidRuntime(30168): ... 14 more
09-19 18:49:17.259: E/AndroidRuntime(30750): FATAL EXCEPTION: main
09-19 18:49:17.259: E/AndroidRuntime(30750): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.view.View$1.onClick(View.java:3633)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.view.View.performClick(View.java:4240)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.os.Looper.loop(Looper.java:137)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:49:17.259: E/AndroidRuntime(30750): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:49:17.259: E/AndroidRuntime(30750): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:49:17.259: E/AndroidRuntime(30750): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:49:17.259: E/AndroidRuntime(30750): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:49:17.259: E/AndroidRuntime(30750): at dalvik.system.NativeStart.main(Native Method)
09-19 18:49:17.259: E/AndroidRuntime(30750): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:49:17.259: E/AndroidRuntime(30750): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:49:17.259: E/AndroidRuntime(30750): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.view.View$1.onClick(View.java:3628)
09-19 18:49:17.259: E/AndroidRuntime(30750): ... 11 more
09-19 18:49:17.259: E/AndroidRuntime(30750): Caused by: java.lang.NullPointerException: println needs a message
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.util.Log.println_native(Native Method)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.util.Log.e(Log.java:231)
09-19 18:49:17.259: E/AndroidRuntime(30750): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:49:17.259: E/AndroidRuntime(30750): ... 14 more
09-19 18:50:39.907: E/AndroidRuntime(31052): FATAL EXCEPTION: main
09-19 18:50:39.907: E/AndroidRuntime(31052): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.view.View$1.onClick(View.java:3633)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.view.View.performClick(View.java:4240)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.os.Looper.loop(Looper.java:137)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:50:39.907: E/AndroidRuntime(31052): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:50:39.907: E/AndroidRuntime(31052): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:50:39.907: E/AndroidRuntime(31052): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:50:39.907: E/AndroidRuntime(31052): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:50:39.907: E/AndroidRuntime(31052): at dalvik.system.NativeStart.main(Native Method)
09-19 18:50:39.907: E/AndroidRuntime(31052): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:50:39.907: E/AndroidRuntime(31052): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:50:39.907: E/AndroidRuntime(31052): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.view.View$1.onClick(View.java:3628)
09-19 18:50:39.907: E/AndroidRuntime(31052): ... 11 more
09-19 18:50:39.907: E/AndroidRuntime(31052): Caused by: java.lang.NullPointerException: println needs a message
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.util.Log.println_native(Native Method)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.util.Log.println(Log.java:332)
09-19 18:50:39.907: E/AndroidRuntime(31052): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:50:39.907: E/AndroidRuntime(31052): ... 14 more
09-19 18:51:10.640: E/AndroidRuntime(31288): FATAL EXCEPTION: main
09-19 18:51:10.640: E/AndroidRuntime(31288): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.view.View$1.onClick(View.java:3633)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.view.View.performClick(View.java:4240)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.os.Looper.loop(Looper.java:137)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:51:10.640: E/AndroidRuntime(31288): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:51:10.640: E/AndroidRuntime(31288): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:51:10.640: E/AndroidRuntime(31288): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:51:10.640: E/AndroidRuntime(31288): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:51:10.640: E/AndroidRuntime(31288): at dalvik.system.NativeStart.main(Native Method)
09-19 18:51:10.640: E/AndroidRuntime(31288): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:51:10.640: E/AndroidRuntime(31288): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:51:10.640: E/AndroidRuntime(31288): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.view.View$1.onClick(View.java:3628)
09-19 18:51:10.640: E/AndroidRuntime(31288): ... 11 more
09-19 18:51:10.640: E/AndroidRuntime(31288): Caused by: java.lang.NullPointerException
09-19 18:51:10.640: E/AndroidRuntime(31288): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:51:10.640: E/AndroidRuntime(31288): ... 14 more
09-19 18:54:51.165: E/AndroidRuntime(31543): FATAL EXCEPTION: main
09-19 18:54:51.165: E/AndroidRuntime(31543): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.view.View$1.onClick(View.java:3633)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.view.View.performClick(View.java:4240)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.os.Looper.loop(Looper.java:137)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:54:51.165: E/AndroidRuntime(31543): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:54:51.165: E/AndroidRuntime(31543): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:54:51.165: E/AndroidRuntime(31543): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:54:51.165: E/AndroidRuntime(31543): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:54:51.165: E/AndroidRuntime(31543): at dalvik.system.NativeStart.main(Native Method)
09-19 18:54:51.165: E/AndroidRuntime(31543): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:54:51.165: E/AndroidRuntime(31543): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:54:51.165: E/AndroidRuntime(31543): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.view.View$1.onClick(View.java:3628)
09-19 18:54:51.165: E/AndroidRuntime(31543): ... 11 more
09-19 18:54:51.165: E/AndroidRuntime(31543): Caused by: java.lang.NullPointerException
09-19 18:54:51.165: E/AndroidRuntime(31543): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:54:51.165: E/AndroidRuntime(31543): ... 14 more
this is error i get in my logcat.
when I call androidHttpTransport.call(SOAP_ACTION, envelope);
I get exception null, and i enter catch statement. why? any help?
krikor1 said:
I do that, i get my first app has to be stopped
Code:
09-19 18:47:05.798: E/AndroidRuntime(29848): FATAL EXCEPTION: main
09-19 18:47:05.798: E/AndroidRuntime(29848): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.view.View$1.onClick(View.java:3633)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.view.View.performClick(View.java:4240)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.os.Looper.loop(Looper.java:137)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:47:05.798: E/AndroidRuntime(29848): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:47:05.798: E/AndroidRuntime(29848): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:47:05.798: E/AndroidRuntime(29848): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:47:05.798: E/AndroidRuntime(29848): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:47:05.798: E/AndroidRuntime(29848): at dalvik.system.NativeStart.main(Native Method)
09-19 18:47:05.798: E/AndroidRuntime(29848): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:47:05.798: E/AndroidRuntime(29848): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:47:05.798: E/AndroidRuntime(29848): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.view.View$1.onClick(View.java:3628)
09-19 18:47:05.798: E/AndroidRuntime(29848): ... 11 more
09-19 18:47:05.798: E/AndroidRuntime(29848): Caused by: java.lang.NullPointerException: println needs a message
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.util.Log.println_native(Native Method)
09-19 18:47:05.798: E/AndroidRuntime(29848): at android.util.Log.d(Log.java:138)
09-19 18:47:05.798: E/AndroidRuntime(29848): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:47:05.798: E/AndroidRuntime(29848): ... 14 more
09-19 18:47:30.955: E/AndroidRuntime(30168): FATAL EXCEPTION: main
09-19 18:47:30.955: E/AndroidRuntime(30168): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.view.View$1.onClick(View.java:3633)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.view.View.performClick(View.java:4240)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.os.Looper.loop(Looper.java:137)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:47:30.955: E/AndroidRuntime(30168): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:47:30.955: E/AndroidRuntime(30168): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:47:30.955: E/AndroidRuntime(30168): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:47:30.955: E/AndroidRuntime(30168): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:47:30.955: E/AndroidRuntime(30168): at dalvik.system.NativeStart.main(Native Method)
09-19 18:47:30.955: E/AndroidRuntime(30168): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:47:30.955: E/AndroidRuntime(30168): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:47:30.955: E/AndroidRuntime(30168): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.view.View$1.onClick(View.java:3628)
09-19 18:47:30.955: E/AndroidRuntime(30168): ... 11 more
09-19 18:47:30.955: E/AndroidRuntime(30168): Caused by: java.lang.NullPointerException: println needs a message
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.util.Log.println_native(Native Method)
09-19 18:47:30.955: E/AndroidRuntime(30168): at android.util.Log.d(Log.java:138)
09-19 18:47:30.955: E/AndroidRuntime(30168): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:47:30.955: E/AndroidRuntime(30168): ... 14 more
09-19 18:49:17.259: E/AndroidRuntime(30750): FATAL EXCEPTION: main
09-19 18:49:17.259: E/AndroidRuntime(30750): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.view.View$1.onClick(View.java:3633)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.view.View.performClick(View.java:4240)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.os.Looper.loop(Looper.java:137)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:49:17.259: E/AndroidRuntime(30750): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:49:17.259: E/AndroidRuntime(30750): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:49:17.259: E/AndroidRuntime(30750): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:49:17.259: E/AndroidRuntime(30750): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:49:17.259: E/AndroidRuntime(30750): at dalvik.system.NativeStart.main(Native Method)
09-19 18:49:17.259: E/AndroidRuntime(30750): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:49:17.259: E/AndroidRuntime(30750): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:49:17.259: E/AndroidRuntime(30750): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.view.View$1.onClick(View.java:3628)
09-19 18:49:17.259: E/AndroidRuntime(30750): ... 11 more
09-19 18:49:17.259: E/AndroidRuntime(30750): Caused by: java.lang.NullPointerException: println needs a message
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.util.Log.println_native(Native Method)
09-19 18:49:17.259: E/AndroidRuntime(30750): at android.util.Log.e(Log.java:231)
09-19 18:49:17.259: E/AndroidRuntime(30750): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:49:17.259: E/AndroidRuntime(30750): ... 14 more
09-19 18:50:39.907: E/AndroidRuntime(31052): FATAL EXCEPTION: main
09-19 18:50:39.907: E/AndroidRuntime(31052): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.view.View$1.onClick(View.java:3633)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.view.View.performClick(View.java:4240)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.os.Looper.loop(Looper.java:137)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:50:39.907: E/AndroidRuntime(31052): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:50:39.907: E/AndroidRuntime(31052): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:50:39.907: E/AndroidRuntime(31052): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:50:39.907: E/AndroidRuntime(31052): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:50:39.907: E/AndroidRuntime(31052): at dalvik.system.NativeStart.main(Native Method)
09-19 18:50:39.907: E/AndroidRuntime(31052): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:50:39.907: E/AndroidRuntime(31052): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:50:39.907: E/AndroidRuntime(31052): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.view.View$1.onClick(View.java:3628)
09-19 18:50:39.907: E/AndroidRuntime(31052): ... 11 more
09-19 18:50:39.907: E/AndroidRuntime(31052): Caused by: java.lang.NullPointerException: println needs a message
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.util.Log.println_native(Native Method)
09-19 18:50:39.907: E/AndroidRuntime(31052): at android.util.Log.println(Log.java:332)
09-19 18:50:39.907: E/AndroidRuntime(31052): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:50:39.907: E/AndroidRuntime(31052): ... 14 more
09-19 18:51:10.640: E/AndroidRuntime(31288): FATAL EXCEPTION: main
09-19 18:51:10.640: E/AndroidRuntime(31288): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.view.View$1.onClick(View.java:3633)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.view.View.performClick(View.java:4240)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.os.Looper.loop(Looper.java:137)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:51:10.640: E/AndroidRuntime(31288): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:51:10.640: E/AndroidRuntime(31288): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:51:10.640: E/AndroidRuntime(31288): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:51:10.640: E/AndroidRuntime(31288): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:51:10.640: E/AndroidRuntime(31288): at dalvik.system.NativeStart.main(Native Method)
09-19 18:51:10.640: E/AndroidRuntime(31288): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:51:10.640: E/AndroidRuntime(31288): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:51:10.640: E/AndroidRuntime(31288): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:51:10.640: E/AndroidRuntime(31288): at android.view.View$1.onClick(View.java:3628)
09-19 18:51:10.640: E/AndroidRuntime(31288): ... 11 more
09-19 18:51:10.640: E/AndroidRuntime(31288): Caused by: java.lang.NullPointerException
09-19 18:51:10.640: E/AndroidRuntime(31288): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:51:10.640: E/AndroidRuntime(31288): ... 14 more
09-19 18:54:51.165: E/AndroidRuntime(31543): FATAL EXCEPTION: main
09-19 18:54:51.165: E/AndroidRuntime(31543): java.lang.IllegalStateException: Could not execute method of the activity
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.view.View$1.onClick(View.java:3633)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.view.View.performClick(View.java:4240)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.view.View$PerformClick.run(View.java:17721)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.os.Handler.handleCallback(Handler.java:730)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.os.Handler.dispatchMessage(Handler.java:92)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.os.Looper.loop(Looper.java:137)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-19 18:54:51.165: E/AndroidRuntime(31543): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:54:51.165: E/AndroidRuntime(31543): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:54:51.165: E/AndroidRuntime(31543): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-19 18:54:51.165: E/AndroidRuntime(31543): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-19 18:54:51.165: E/AndroidRuntime(31543): at dalvik.system.NativeStart.main(Native Method)
09-19 18:54:51.165: E/AndroidRuntime(31543): Caused by: java.lang.reflect.InvocationTargetException
09-19 18:54:51.165: E/AndroidRuntime(31543): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 18:54:51.165: E/AndroidRuntime(31543): at java.lang.reflect.Method.invoke(Method.java:525)
09-19 18:54:51.165: E/AndroidRuntime(31543): at android.view.View$1.onClick(View.java:3628)
09-19 18:54:51.165: E/AndroidRuntime(31543): ... 11 more
09-19 18:54:51.165: E/AndroidRuntime(31543): Caused by: java.lang.NullPointerException
09-19 18:54:51.165: E/AndroidRuntime(31543): at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:82)
09-19 18:54:51.165: E/AndroidRuntime(31543): ... 14 more
this is error i get in my logcat.
Click to expand...
Click to collapse
According to the logcat, you didn't enter a message.
---------- Post added at 06:09 PM ---------- Previous post was at 06:09 PM ----------
krikor1 said:
when I call androidHttpTransport.call(SOAP_ACTION, envelope);
I get exception null, and i enter catch statement. why? any help?
Click to expand...
Click to collapse
This might help you finding the reason for the NPE: http://forum.xda-developers.com/showthread.php?t=2325164
Hello there,
I am trying to learn android application development through one of the online tutorials .I am stuck at a point and since,both java and android are new for me I can't figure out how to get out of it.Here's the code to my Startingpoint.java:
Code:
public class Startingpoint extends Activity {
int counter;
Button add,sub;
TextView display;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
counter=0;
add=(Button)findViewById(R.id.bAdd);
sub=(Button)findViewById(R.id.bSub);
display=(TextView)findViewById(R.id.display);
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counter++;
display.setText("Your total is " + counter);
}
});
sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counter--;
display.setText("Your total is" + counter);
}
});
}
}
The following are the contents within the LineaLlayout in my main.xml file:
Code:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/result"
android:textSize="25sp"
android:layout_gravity="fill_horizontal"
android:gravity="center"
android:id="@+id/display"
/>
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="@string/bAdd"
android:layout_gravity="center"
android:gravity="center"
android:id="@+id/bAdd"
/>
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="@string/bSub"
android:layout_gravity="center"
android:gravity="center"
android:id="@+id/bSub"
/>
And this is what the logcat has to say :
Code:
02-13 11:44:12.076: D/AndroidRuntime(2026): Shutting down VM
02-13 11:44:12.076: W/dalvikvm(2026): threadid=1: thread exiting with uncaught exception (group=0xb2d5bb08)
02-13 11:44:12.156: E/AndroidRuntime(2026): FATAL EXCEPTION: main
02-13 11:44:12.156: E/AndroidRuntime(2026): Process: com.thenewboston.rohit, PID: 2026
02-13 11:44:12.156: E/AndroidRuntime(2026): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thenewboston.rohit/com.thenewboston.rohit.Startingpoint}: java.lang.NullPointerException
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread.access$700(ActivityThread.java:135)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.os.Handler.dispatchMessage(Handler.java:102)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.os.Looper.loop(Looper.java:137)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread.main(ActivityThread.java:4998)
02-13 11:44:12.156: E/AndroidRuntime(2026): at java.lang.reflect.Method.invokeNative(Native Method)
02-13 11:44:12.156: E/AndroidRuntime(2026): at java.lang.reflect.Method.invoke(Method.java:515)
02-13 11:44:12.156: E/AndroidRuntime(2026): atcom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
02-13 11:44:12.156: E/AndroidRuntime(2026): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
02-13 11:44:12.156: E/AndroidRuntime(2026): at dalvik.system.NativeStart.main(Native Method)
02-13 11:44:12.156: E/AndroidRuntime(2026): Caused by: java.lang.NullPointerException
02-13 11:44:12.156: E/AndroidRuntime(2026): at com.thenewboston.rohit.Startingpoint.onCreate(Startingpoint.java:21)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.Activity.performCreate(Activity.java:5243)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-13 11:44:12.156: E/AndroidRuntime(2026): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
02-13 11:44:12.156: E/AndroidRuntime(2026): ... 11 more
Being inexperienced in java , I could not figure out what's wrong with the code.May be the exception is due to my add,sub and display being null but I am not sure.Please help me figure out what's wrong with my code and how to deal with it.
Any help is greatly appreciated.
Well, you can find the line where it crashes in the logcat:
Code:
02-13 11:44:12.156: E/AndroidRuntime(2026): Caused by: java.lang.NullPointerException
02-13 11:44:12.156: E/AndroidRuntime(2026): at com.thenewboston.rohit.Startingpoint.onCreate([B]Startingpoint.java:21[/B])
It's line 21. Which one is that?
Have a look at my debugging tutorial here as well, mainly the part on understanding the logcat. It will probably be very helpful and save much time: http://forum.xda-developers.com/showthread.php?t=2325164
nikwen said:
Well, you can find the line where it crashes in the logcat:
Code:
02-13 11:44:12.156: E/AndroidRuntime(2026): Caused by: java.lang.NullPointerException
02-13 11:44:12.156: E/AndroidRuntime(2026): at com.thenewboston.rohit.Startingpoint.onCreate([B]Startingpoint.java:21[/B])
It's line 21. Which one is that?
Have a look at my debugging tutorial here as well, mainly the part on understanding the logcat. It will probably be very helpful and save much time: http://forum.xda-developers.com/showthread.php?t=2325164
Click to expand...
Click to collapse
I bet they must be the findViewById(int id);
as much i trust my counting skills line 21 is calling for one the views
i still remeber the first NPE when i started android
Sent from my GT-S5302 using Tapatalk 2
I am sorry , I should have mentioned it.
Line 21 -> add.setOnClickListener(new View.OnClickListener()
DarkMethod said:
I am sorry , I should have mentioned it.
Line 21 -> add.setOnClickListener(new View.OnClickListener()
Click to expand...
Click to collapse
It means the.view with id bAdd was not found make sure have declared it in your layout
Sent from my GT-S5302 using Tapatalk 2
I have declared the ids for each view as you can see in the layout.xml attached.This NPE is turning out to be quite frustrating now.
DarkMethod said:
I have declared the ids for each view as you can see in the layout.xml attached.This NPE is turning out to be quite frustrating now.
Click to expand...
Click to collapse
do one thing
add a breakpoint to each line
then debug your app if on Eclipse or Android Studio !
and watch the control flow through each line this should narrow you down to the root cause.
Sent from my GT-S5302 using Tapatalk 2
sak-venom1997 said:
do one thing
add a breakpoint to each line
then debug your app if on Eclipse or Android Studio !
and watch the control flow through each line this should narrow you down to the root cause.
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
More on that here as well: http://forum.xda-developers.com/showthread.php?t=2325164
nikwen said:
More on that here as well: http://forum.xda-developers.com/showthread.php?t=2325164
Click to expand...
Click to collapse
indeed a great one :thumbup:
Sent from my GT-S5302 using Tapatalk 2
sak-venom1997 said:
indeed a great one :thumbup:
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
Thanks.
Hello,
I make an FTP client on Android, for a school project.
I have the layout with the name, host, port number, user, pass and the home directory.
I want to handle the ftp format like : ftps://<username>@<hostname>:<port>/<path>/
If the user input ftp:// or ftps://, I want to "delete" inputs and to display input that are missing.
More, if the ftp link have a missing information like the port, the input need to stay, because the format isn't good.
Here is my code :
Code:
hote.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s)
{
//String ftp = "ftps://arthur:@ftp.example.com:990";
if ((s.subSequence(0, 1)).equals("s"))
{
sftp.setChecked(true);
}
//utlisateur=extraitChaine("/",":");
password.setText(extraitChaine(":","@"));
hote.setText(extraitChaine("@",""));
port.setText(extraitChaine(":",""));
}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
}
// The aim is to extract subsring from char to char
private String extraitChaine(String debut, String fin) {
return "";
}
});
The logcat with a lot of red lines :
Code:
05-31 09:11:30.647: D/AndroidRuntime(1944): Shutting down VM
05-31 09:11:30.647: W/dalvikvm(1944): threadid=1: thread exiting with uncaught exception (group=0xb0f76648)
05-31 09:11:30.647: E/AndroidRuntime(1944): FATAL EXCEPTION: main
05-31 09:11:30.647: E/AndroidRuntime(1944): java.lang.IndexOutOfBoundsException: getChars (0 ... 1) ends beyond length 0
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1016)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.text.SpannableStringBuilder.getChars(SpannableStringBuilder.java:913)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.text.TextUtils.getChars(TextUtils.java:77)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.text.SpannableStringBuilder.<init>(SpannableStringBuilder.java:61)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.text.SpannableStringBuilder.subSequence(SpannableStringBuilder.java:905)
05-31 09:11:30.647: E/AndroidRuntime(1944): at com.example.ynovandroid.activity.InfoFTPActivity$1.afterTextChanged(InfoFTPActivity.java:124)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.widget.TextView.sendAfterTextChanged(TextView.java:7334)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.widget.TextView.setText(TextView.java:3778)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.widget.TextView.setText(TextView.java:3629)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.widget.EditText.setText(EditText.java:80)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.widget.TextView.setText(TextView.java:3604)
05-31 09:11:30.647: E/AndroidRuntime(1944): at com.example.ynovandroid.activity.InfoFTPActivity$1.afterTextChanged(InfoFTPActivity.java:130)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.widget.TextView.sendAfterTextChanged(TextView.java:7334)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:9087)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:970)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:497)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:435)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:30)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.text.method.QwertyKeyListener.onKeyDown(QwertyKeyListener.java:223)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.text.method.TextKeyListener.onKeyDown(TextKeyListener.java:136)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.widget.TextView.doKeyDown(TextView.java:5464)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.widget.TextView.onKeyDown(TextView.java:5283)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.KeyEvent.dispatch(KeyEvent.java:2623)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.View.dispatchKeyEvent(View.java:7343)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
05-31 09:11:30.647: E/AndroidRuntime(1944): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1933)
05-31 09:11:30.647: E/AndroidRuntime(1944): at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1408)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.app.Activity.dispatchKeyEvent(Activity.java:2384)
05-31 09:11:30.647: E/AndroidRuntime(1944): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1860)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3791)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3774)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3516)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3666)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:1982)
05-31 09:11:30.647: E/AndroidRuntime(1944): at android.view.inputmethod.InputMethodManager.invokeF
05-31 09:11:33.597: D/gralloc_goldfish(1995): Emulator without GPU emulation detected.
I try to test my code, after the first letter, the application stop working.
Can you help me ?
Can't you use this?
protocol = GETTEXT.split("://")[0];
user = GETTEXT.split("://")[1].split("@")[0];
server = GETTEXT.split("://")[1].split("@")[1].split(":")[0];
port = GETTEXT.split("://")[1].split("@")[1].split(":")[1].split("/")[0];
path = GETTEXT.split("://")[1].split("@")[1].split(":")[1].split("/")[1];
Your listener is working fine, what isn't is your code. Look at what the log is telling you, you have errors on lines 124 and 130. It's all in the logs.
Hello,
sftp is a checkbox, here is my code:
Code:
public void interceptionLienFTP()
{
hote.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s)
{
//String ftp = "ftps://arthur:@ftp.example.com:990";
String lienFTP = s.toString();
if ((lienFTP.subSequence(0, 1)).equals("s"))
{
sftp.setChecked(true);
}
else
sftp.setChecked(false);
}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
}
});
}
The logcat :
Code:
6-03 09:01:16.131: E/AndroidRuntime(2163): FATAL EXCEPTION: main
06-03 09:01:16.131: E/AndroidRuntime(2163): java.lang.StringIndexOutOfBoundsException: length=0; regionStart=0; regionLength=1
06-03 09:01:16.131: E/AndroidRuntime(2163): at java.lang.String.startEndAndLength(String.java:583)
06-03 09:01:16.131: E/AndroidRuntime(2163): at java.lang.String.substring(String.java:1464)
06-03 09:01:16.131: E/AndroidRuntime(2163): at java.lang.String.subSequence(String.java:1851)
06-03 09:01:16.131: E/AndroidRuntime(2163): at com.example.ynovandroid.activity.InfoFTPActivity$1.afterTextChanged(InfoFTPActivity.java:120)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.widget.TextView.sendAfterTextChanged(TextView.java:7334)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:9087)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:970)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:497)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:212)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:30)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.text.method.BaseKeyListener.backspaceOrForwardDelete(BaseKeyListener.java:94)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.text.method.BaseKeyListener.backspace(BaseKeyListener.java:49)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.text.method.BaseKeyListener.onKeyDown(BaseKeyListener.java:155)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.text.method.QwertyKeyListener.onKeyDown(QwertyKeyListener.java:357)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.text.method.TextKeyListener.onKeyDown(TextKeyListener.java:136)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.widget.TextView.doKeyDown(TextView.java:5464)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.widget.TextView.onKeyDown(TextView.java:5283)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.KeyEvent.dispatch(KeyEvent.java:2623)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.View.dispatchKeyEvent(View.java:7343)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
06-03 09:01:16.131: E/AndroidRuntime(2163): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1933)
06-03 09:01:16.131: E/AndroidRuntime(2163): at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1408)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.app.Activity.dispatchKeyEvent(Activity.java:2384)
06-03 09:01:16.131: E/AndroidRuntime(2163): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1860)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3791)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3774)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3516)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3666)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:1982)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1698)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1689)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:1959)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
06-03 09:01:16.131: E/AndroidRuntime(2163): at android.os
How I can uncheck it ?
I'll apply the same code for all textview.
tim91700 said:
Hello,
sftp is a checkbox, here is my code:
Code:
public void interceptionLienFTP()
{
hote.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s)
{
//String ftp = "ftps://arthur:@ftp.example.com:990";
String lienFTP = s.toString();
if ((lienFTP.subSequence(0, 1)).equals("s"))
{
sftp.setChecked(true);
}
else
sftp.setChecked(false);
}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
}
});
}
How I can uncheck it ?
I'll apply the same code for all textview.
Click to expand...
Click to collapse
It looks fine, you get the error on your call to lienFTP.subSequence(0,1) because you didn't check if the string is long enough! So just add a "lienFTP.length()>0 && " before it in the condition.
Hello,
I forgot this point, thanks you.
Now, I have a working code :
Code:
if ( lienFTP.length()>3 && ((lienFTP.subSequence(0, 3)).equals("ftp")) && ((lienFTP.subSequence(3, 4)).equals("s")))
{
sftp.setChecked(true);
}
The next goal is to handle thue user (to begin).
My idea is to make a while under a while and on.
Like if the lienFTP.contains("://") so, the application wait for the next "@" to set the text of the user input.
Code:
while(lienFTP.contains("://"))
{
if(lienFTP.contains("@"))
{
utilisateur.setText(lienFTP.split("://")[1].split("@")[0]);
}
}
Do you agree with my point of view or it's too much ?
tim91700 said:
Hello,
I forgot this point, thanks you.
Now, I have a working code :
Code:
if ( lienFTP.length()>3 && ((lienFTP.subSequence(0, 3)).equals("ftp")) && ((lienFTP.subSequence(3, 4)).equals("s")))
{
sftp.setChecked(true);
}
The next goal is to handle thue user (to begin).
My idea is to make a while under a while and on.
Like if the lienFTP.contains("://") so, the application wait for the next "@" to set the text of the user input.
Code:
while(lienFTP.contains("://"))
{
if(lienFTP.contains("@"))
{
utilisateur.setText(lienFTP.split("://")[1].split("@")[0]);
}
}
Do you agree with my point of view or it's too much ?
Click to expand...
Click to collapse
I don't really get what you mean, but using a while loop in the main thread will block the ui, and thus the user can not enter anything.
GalaxyInABox said:
I don't really get what you mean, but using a while loop in the main thread will block the ui, and thus the user can not enter anything.
Click to expand...
Click to collapse
I take an example to show you :
The user input ftps://, so the check box is checked
I continue with arthur and he put ":", to enter a password.
How dynamically set the text for the textview of the username between "://" and ":" ?
And if the input of the user "go back" and erase characters, how to erase the content of the textview ?
If the user input this : ftps://arthurftp.example.com:990/www/
The password part is missing, so I need to focus this textview, and handle the empty part.
Here is the list of char, to split the full input : "://",":","@",":","/".
First of all. Do I get you right that you have ONE textfield where you enter your credentials/the ftp stuff, and multiple ones which show the actual parts, like server, port user and so on?
tim91700 said:
I take an example to show you :
The user input ftps://, so the check box is checked
I continue with arthur and he put ":", to enter a password.
How dynamically set the text for the textview of the username between "://" and ":" ?
And if the input of the user "go back" and erase characters, how to erase the content of the textview ?
Click to expand...
Click to collapse
Use the listener. Use aftertextchanged and if the last char of the string(i think aftertextchanged actually returns an editable, but thats not a problem) is a ":" and the textbox has a set number of ":" chars, add text to it(but i dont know why you would like to do this automatically because it will result in a loop). I would suggest using multiple textfields, one for each part of the adress, make the inputtype the keyboard with the 'done' or 'next' button, and go from box to box. To get the result, you can use String.format with something like this: String url = String.format("%s://%s:%[email protected]%s:/", the edittext.getText().toString() as varags...). And maybe create a checkbox for ftp/sftp, making the protocol string either "ftp" or "sftp".
Gesendet von meinem SM-N9005 mit Tapatalk
Hello,
Here is my layout to add ftp server : http://gyazo.com/252e3bbf74e6d34c1e6c9959666065a9
I add this listener to host and name input.
The aim is to copy the ftp:// to one or the other input, and separate it directly to other textview.
Because, on the button "Ajouter", the onclic method take all input.gettext().tostring() to insert it to an SQLite database.
So maybe it's this way : (pseudo code)
I create a tab with all delimiters, and get each text between then.
I use try and catch, because all delimiters will not be present sometime.
My idea is good ?
Hello,
I'm currently developing an application that uses the facebook SDK. On the emulator everything goes fine but the problem is in the real device.
I've setup the Hashkeys, i previously received the error "Invalid hash key not found in the application" and successfully fixed it. But now i'm having another problem.
Whenever i click a button (which is intended to call the Facebook sdk) the facebook activity pops in and suddenly the facebook activity closes. Supposedly, it should appears the Facebook share window. Here's the code that i'm using on that button:
Code:
APP_ID = getString(R.string.facebook_app_id);
fb = new Facebook(APP_ID);
fb.authorize(QuestionsActivity.this, new Facebook.DialogListener() {
@Override
public void onComplete(Bundle values) {
Bundle params = new Bundle();
params.putString("name","I need your help!");
params.putString("caption","Could you give me a help please?");
params.putString("description", labelQuestion.getText().toString() + " A)" + answerA.getText() + " B)" + answerB.getText() + " C)" + answerC.getText());
params.putString("picture", "link");
params.putString("link,"link");
fb.dialog(QuestionsActivity.this,"feed",params,new Facebook.DialogListener() {
@Override
public void onComplete(Bundle values) {
ShowScoreIncrement(10);
Log.d("DEBUGA","A");
}
@Override
public void onFacebookError(FacebookError e) {
Log.d("DEBUGA","B");
}
@Override
public void onError(DialogError e) {
Log.d("DEBUGA","C");
}
@Override
public void onCancel() {
Log.d("DEBUGA","D");
}
});
}
@Override
public void onFacebookError(FacebookError e) {
Log.d("FB","Error" + e.getMessage());
}
@Override
public void onError(DialogError e) {
Log.d("FB", "Complete" + e.getMessage());
}
@Override
public void onCancel() {
Log.d("FB","Cancel");
}
});
As for logging info:
Code:
12-27 21:36:49.737 6220-6220/com.angelo.assassinscreedquiz I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.006_msm8610_LNX.LA.3.5.1_RB1__release_AU ()
OpenGL ES Shader Compiler Version: E031.24.00.07
Build Date: 02/12/14 Wed
Local Branch:
Remote Branch: quic/LNX.LA.3.5.1_RB1.1
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.006 + NOTHING
12-27 21:36:49.997 6220-6220/com.angelo.assassinscreedquiz D/OpenGLRenderer﹕ Enabling debug mode 0
12-27 21:36:50.027 6220-6220/com.angelo.assassinscreedquiz D/tcd﹕ process windowFocusChanged msg
12-27 21:36:50.237 6220-6220/com.angelo.assassinscreedquiz I/ActivityManager﹕ Timeline: Activity_idle id: [email protected] time:40737600
12-27 21:36:51.207 6220-6220/com.angelo.assassinscreedquiz I/ActivityManager﹕ Timeline: Activity_launch_request id:com.angelo.assassinscreedquiz time:40738579
12-27 21:36:51.217 6220-6232/com.angelo.assassinscreedquiz D/tcd﹕ Focus to false
12-27 21:36:51.227 6220-6220/com.angelo.assassinscreedquiz D/tcd﹕ process windowFocusChanged msg
12-27 21:36:51.277 6220-6220/com.angelo.assassinscreedquiz D/RANDOM﹕ 6
12-27 21:36:51.277 6220-6220/com.angelo.assassinscreedquiz D/RANDOM﹕ 18
12-27 21:36:51.277 6220-6220/com.angelo.assassinscreedquiz D/RANDOM﹕ 19
12-27 21:36:51.277 6220-6220/com.angelo.assassinscreedquiz D/RANDOM﹕ 8
12-27 21:36:51.277 6220-6220/com.angelo.assassinscreedquiz D/RANDOM﹕ 14
12-27 21:36:51.277 6220-6220/com.angelo.assassinscreedquiz D/RANDOM﹕ 0
12-27 21:36:51.277 6220-6220/com.angelo.assassinscreedquiz D/RANDOM﹕ 16
12-27 21:36:51.277 6220-6220/com.angelo.assassinscreedquiz D/RANDOM﹕ 3
12-27 21:36:51.277 6220-6220/com.angelo.assassinscreedquiz D/RANDOM﹕ 1
12-27 21:36:51.277 6220-6220/com.angelo.assassinscreedquiz D/RANDOM﹕ 4
12-27 21:36:51.357 6220-6220/com.angelo.assassinscreedquiz D/dalvikvm﹕ GC_FOR_ALLOC freed 171K, 6% free 4522K/4764K, paused 16ms, total 16ms
12-27 21:36:51.357 6220-6220/com.angelo.assassinscreedquiz I/dalvikvm-heap﹕ Grow heap (frag case) to 5.587MB for 635812-byte allocation
12-27 21:36:51.457 6220-6230/com.angelo.assassinscreedquiz D/tcd﹕ Focus to true
12-27 21:36:51.457 6220-6244/com.angelo.assassinscreedquiz D/QUESTION﹕ 6
12-27 21:36:51.457 6220-6244/com.angelo.assassinscreedquiz D/data_question﹕ Question3
12-27 21:36:51.577 6220-6220/com.angelo.assassinscreedquiz D/tcd﹕ process windowFocusChanged msg
12-27 21:36:51.577 6220-6220/com.angelo.assassinscreedquiz D/tcd﹕ imm = [email protected] falseflg=#1820002
12-27 21:36:51.597 6220-6230/com.angelo.assassinscreedquiz D/tcd﹕ Focus to true
12-27 21:36:51.757 6220-6220/com.angelo.assassinscreedquiz D/tcd﹕ process windowFocusChanged msg
12-27 21:36:51.777 6220-6231/com.angelo.assassinscreedquiz D/tcd﹕ Focus to false
12-27 21:36:51.867 6220-6220/com.angelo.assassinscreedquiz I/ActivityManager﹕ Timeline: Activity_idle id: [email protected] time:40739238
12-27 21:36:54.117 6220-6220/com.angelo.assassinscreedquiz D/dalvikvm﹕ GC_FOR_ALLOC freed 178K, 5% free 5477K/5724K, paused 11ms, total 11ms
12-27 21:36:54.117 6220-6220/com.angelo.assassinscreedquiz I/ActivityManager﹕ Timeline: Activity_launch_request id:com.facebook.katana time:40741484
12-27 21:36:54.127 6220-6232/com.angelo.assassinscreedquiz D/tcd﹕ Focus to false
12-27 21:36:54.127 6220-6220/com.angelo.assassinscreedquiz D/QUESTIONSACTIVITY﹕ It was paused
12-27 21:36:54.137 6220-6220/com.angelo.assassinscreedquiz D/tcd﹕ process windowFocusChanged msg
12-27 21:36:56.387 6220-6232/com.angelo.assassinscreedquiz D/tcd﹕ Focus to true
12-27 21:36:56.387 6220-6220/com.angelo.assassinscreedquiz D/tcd﹕ process windowFocusChanged msg
12-27 21:36:56.617 6220-6220/com.angelo.assassinscreedquiz I/ActivityManager﹕ Timeline: Activity_idle id: [email protected] time:40743989
12-27 21:37:09.457 6220-6220/com.angelo.assassinscreedquiz D/QUESTIONSACTIVITY﹕ It was paused
12-27 21:37:09.597 6220-6220/com.angelo.assassinscreedquiz W/IInputConnectionWrapper﹕ getExtractedText on inactive InputConnection
12-27 21:37:09.597 6220-6220/com.angelo.assassinscreedquiz W/IInputConnectionWrapper﹕ getTextBeforeCursor on inactive InputConnection
12-27 21:37:09.597 6220-6220/com.angelo.assassinscreedquiz W/IInputConnectionWrapper﹕ getSelectedText on inactive InputConnection
12-27 21:37:09.597 6220-6220/com.angelo.assassinscreedquiz W/IInputConnectionWrapper﹕ getTextAfterCursor on inactive InputConnection
12-27 21:37:14.977 6220-6232/com.angelo.assassinscreedquiz D/tcd﹕ Focus to false
12-27 21:37:14.977 6220-6220/com.angelo.assassinscreedquiz D/tcd﹕ process windowFocusChanged msg
Anyone has an idea about what might be happening? Thank you before hand!