lundi 29 juin 2015

Error in starting emulator in android studio


I got this error when start emulator please help me i tried many solutions. Updated graphics drivers, ram changes and screen resolution is 1280*1024.

Logcat error:

Failed to create Context 0x3005
could not get wglGetExtensionsStringARB
emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
could not get wglGetExtensionsStringARB
emulator: device fd:512
could not get wglGetExtensionsStringARB
Could not initialize emulated framebufferHAX is not working and emulator runs in emulation mode
emulator: The memory needed by this VM exceeds the driver limit.
ERROR: Could not create window texture: Texture dimensions are limited to 2048x2048


Overwrite default list view highlighted color in AppCompat theme


My application's main theme inherits from Theme.AppCompat, and I've created a selector that allows for the Ripple effect to take place when you press and focus a button on Lollipop.

However, when I go back to a 4.0 device, it defaults back to an ugly blue color when I focus a list view item. I've looked everywhere for the trait that defines this color hoping to override it without any luck - any idea how I can do this?


Android get files from pc folder


I have a problem with the connection from my Android device to my local PC. I want to get all the files from a folder that is shared in my pc to everyone.

This is the code that I have:

private void connectToPC(){
        try {
            String username = "Alex";
            String password = ".";
            String sharedFolder = "Fisiere Date Senzori";
            String path = "smb://"+ip+"/Users/Alex/Documents/"+sharedFolder+"/";

            NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",username,password);
            SmbFile smbFile = new SmbFile(path,auth);

            String[] files = smbFile.list();

            for (String fileName : files) {
                Log.d("log_tag", "Fisier: " + fileName);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

and this is the result that I get:

06-29 22:35:37.752: W/System.err(17081): jcifs.smb.SmbException: Failed to connect to server
06-29 22:35:37.752: W/System.err(17081): java.net.UnknownHostException: null
06-29 22:35:37.752: W/System.err(17081):    at jcifs.UniAddress.getAllByName(UniAddress.java:315)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.getFirstAddress(SmbFile.java:810)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.connect(SmbFile.java:897)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.connect0(SmbFile.java:826)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.resolveDfs(SmbFile.java:664)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.send(SmbFile.java:726)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1930)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.doEnum(SmbFile.java:1682)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.list(SmbFile.java:1653)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.list(SmbFile.java:1550)
06-29 22:35:37.752: W/System.err(17081):    at com.rasp.pi.StartingPoint.connectToPC(StartingPoint.java:149)
06-29 22:35:37.752: W/System.err(17081):    at com.rasp.pi.StartingPoint.onCreate(StartingPoint.java:56)
06-29 22:35:37.752: W/System.err(17081):    at android.app.Activity.performCreate(Activity.java:6289)
06-29 22:35:37.752: W/System.err(17081):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
06-29 22:35:37.752: W/System.err(17081):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2647)
06-29 22:35:37.752: W/System.err(17081):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2759)
06-29 22:35:37.752: W/System.err(17081):    at android.app.ActivityThread.access$900(ActivityThread.java:178)
06-29 22:35:37.752: W/System.err(17081):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
06-29 22:35:37.752: W/System.err(17081):    at android.os.Handler.dispatchMessage(Handler.java:102)
06-29 22:35:37.752: W/System.err(17081):    at android.os.Looper.loop(Looper.java:145)
06-29 22:35:37.752: W/System.err(17081):    at android.app.ActivityThread.main(ActivityThread.java:5944)
06-29 22:35:37.752: W/System.err(17081):    at java.lang.reflect.Method.invoke(Native Method)
06-29 22:35:37.752: W/System.err(17081):    at java.lang.reflect.Method.invoke(Method.java:372)
06-29 22:35:37.752: W/System.err(17081):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
06-29 22:35:37.752: W/System.err(17081):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.connect0(SmbFile.java:828)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.resolveDfs(SmbFile.java:664)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.send(SmbFile.java:726)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1930)
06-29 22:35:37.752: W/System.err(17081):    at jcifs.smb.SmbFile.doEnum(SmbFile.java:1682)
06-29 22:35:37.762: W/System.err(17081):    at jcifs.smb.SmbFile.list(SmbFile.java:1653)
06-29 22:35:37.762: W/System.err(17081):    at jcifs.smb.SmbFile.list(SmbFile.java:1550)
06-29 22:35:37.762: W/System.err(17081):    at com.rasp.pi.StartingPoint.connectToPC(StartingPoint.java:149)
06-29 22:35:37.762: W/System.err(17081):    at com.rasp.pi.StartingPoint.onCreate(StartingPoint.java:56)
06-29 22:35:37.762: W/System.err(17081):    at android.app.Activity.performCreate(Activity.java:6289)
06-29 22:35:37.762: W/System.err(17081):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
06-29 22:35:37.762: W/System.err(17081):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2647)
06-29 22:35:37.772: W/System.err(17081):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2759)
06-29 22:35:37.772: W/System.err(17081):    at android.app.ActivityThread.access$900(ActivityThread.java:178)
06-29 22:35:37.772: W/System.err(17081):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
06-29 22:35:37.772: W/System.err(17081):    at android.os.Handler.dispatchMessage(Handler.java:102)
06-29 22:35:37.772: W/System.err(17081):    at android.os.Looper.loop(Looper.java:145)
06-29 22:35:37.772: W/System.err(17081):    at android.app.ActivityThread.main(ActivityThread.java:5944)
06-29 22:35:37.772: W/System.err(17081):    at java.lang.reflect.Method.invoke(Native Method)
06-29 22:35:37.772: W/System.err(17081):    at java.lang.reflect.Method.invoke(Method.java:372)
06-29 22:35:37.772: W/System.err(17081):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
06-29 22:35:37.772: W/System.err(17081):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

This method is called in onCreate method from an Android Activity. I am using jcifs-1.3.8.jar. What can I do to make this working?

Thanks.


HorizontalScrollView jumps between updates when preforming a scroll animation in tandum with another.


I have a Horizontal ScrollView that I am trying to get to move while at the same time setting the weight of another, separate Linear Layout. The problem is when the view is calculating the weight (or maybe its just when it calculates the new height) of the H-Scrollview it jumps to position 512px and stays there. This makes the scrollview look like it is jumping when the two animations are played together. I have also tried setting just the weight of the scrollview alone and it still does it.

Code that animates the Horizontal Scroll view:

if(currentPlace == 2){
currentPlace--;
if(currentPlace < 0){currentPlace = 0;}

DriverManagerV2.this.getActivity().runOnUiThread(new Runnable() {
    @Override
    public void run() {
        ValueAnimator ani = ValueAnimator.ofInt((int) scroller.getScrollX(), screenWidth *currentPlace);
        ani.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            public void onAnimationUpdate(ValueAnimator animation) {
                LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) lay.getLayoutParams();
                lp.weight = .7f - (.7f*animation.getAnimatedFraction());
                lay.requestLayout();

                LinearLayout.LayoutParams lp2 = (LinearLayout.LayoutParams) scroller.getLayoutParams();
                lp2.weight = 4f + (.7f*animation.getAnimatedFraction());
                scroller.requestLayout();
                scroller.setScrollX((int) animation.getAnimatedValue());
                Log.e("KICKU",""+scroller.getScrollX());
            }
        });
        ani.setDuration(1500);
        ani.start();
    }
});

}

And the XML for the HorizontalScrollView:

 <HorizontalScrollView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:fillViewport="true"
    android:id="@+id/driver_manager_content"
    android:layout_weight="4">

Any idea how to fix this?


glMapBufferRange returning all zeros in Android


I am having trouble reading out from a buffer mapped with glMapBufferRange

If I simply put some data in a buffer

    // Create input VBO and vertex format
    int bufferLength = 5 * 4; //5 floats 4 bytes each
    FloatBuffer data = ByteBuffer.allocateDirect(bufferLength)
            .order(ByteOrder.nativeOrder()).asFloatBuffer();
    float[] floatData = { 1.0f, 4.0f, 9.0f, 16.0f, 25.0f };
    data.put(floatData).position(0);

Generate a Array Buffer in GL and fill it with the data

    int[] vbo = new int[1];
    GLES30.glGenBuffers(1, vbo, 0);
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, vbo[0]);
    GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, bufferLength, data, GLES30.GL_STATIC_DRAW);
    MyGLRenderer.checkGlError(TAG + " glBufferData GL_ARRAY_BUFFER");

When I map the buffer using glMapBufferRange and read the results

    Buffer mappedBuffer =  GLES30.glMapBufferRange(GLES30 .GL_ARRAY_BUFFER,
            0, bufferLength, GLES30.GL_MAP_READ_BIT);

    if (mappedBuffer!=null){
        FloatBuffer transformedBuffer = ((ByteBuffer) mappedBuffer).asFloatBuffer();
        MyGLRenderer.checkGlError(TAG + " glMapBufferRange");

        Log.d(TAG, String.format("pre-run input values = %f %f %f %f %f\n", transformedBuffer.get(),
                transformedBuffer.get(), transformedBuffer.get(), transformedBuffer.get(), transformedBuffer.get()));
        transformedBuffer.position(0);

    }
    GLES30.glUnmapBuffer(GLES30.GL_ARRAY_BUFFER);

The logcat reads all zeros

D/TransformFeedback﹕ pre-run input values = 0.000000 0.000000 0.000000 0.000000 0.000000

No other errors are generated and I am not really sure what else to check. I have tried GLES30.glCopyBufferSubData(GLES30.GL_ARRAY_BUFFER, GLES30.GL_COPY_READ_BUFFER, 0, 0, bufferLength); and mapping GL_COPY_READ_BUFFER and gotten the same results.

I am testing on a Nexus 6 which supports OpenGL ES 3.1 so this functionality should be present.

This question suggests removing the OPENGL_FORWARD_COMPAT hint in glfw, could there be something similar that needs to happen in MyGLSurfaceView?


PARSE this and use for login password edit text condition how i can


{"vsUserName":"d475","vsPassword":"8080","vsIPAddress":"192.168.1.1"}

This is the key value peers which i have to parse in android and used to login and password. I am new in android so no knolege of parsing


Android thread controlling multiple texture views causes strange flickering


I am trying to use a single thread to render three separate TextureView's off the UI thread using canvas lock/unlock. The problem observed is the consistent flickering of each of the Texture Views being drawn, with the flicker consisting of a DIFFERENT TextureView's frame. So for example, I draw frames A,B and C in that order. Frame C will appear fine, however frames A and B will flicker with occasional instances of Frame C, and frame A will occasionally flicker with instances of Frame B.

I have read through the documentation describing Android Core Graphics, and have a fairly good understanding of how android's frame buffering system works. In a nutshell, my suspicion is that I am performing lockCanvas/unlockCanvasAndPost call's too quickly in succession, and that the framebuffer is unable to complete my request and simply draws the previous (incorrect) frame instead.

I've tried several things to resolve this issue. Attempting to use Choreographer to wait for VSYNC before continuing to call canvas helped, but as expected lowered my frame rate however the problem was still there. I've also tried an alternative render loop sans sleep command, with no difference in the observed phenomenon.

Essentially I am out of ideas on how to tackle this problem, and was hoping to get some outside input on it. Thanks in advance, code snippet is below:

Main render loop:

 while (running) {

        long now = System.nanoTime();
        long updateLength = now - lastLoopTime;
        lastLoopTime = now;
        float delta = updateLength / ((float)OPTIMAL_TIME.get());

        lastFpsTime += updateLength;
        fps++;

        if (lastFpsTime >= 1000000000)
        {
            Log.e(TAG, "(FPS Target: " + TARGET_FPS+ " ,FPS Actual: " + fps + ")");
            lastFpsTime = 0;
            fps = 0;
        }


        for (MyTextureView mtv : mItemList){
            if (!mtv.isLocked()) {
                mtv.doUpdate(delta);
                mtv.doRender();
            }
        }

        long sleepTime = (lastLoopTime-System.nanoTime() + OPTIMAL_TIME.get())/1000000;
        sleepTime = sleepTime < 0 ? 0 : sleepTime;

        try{
            Thread.sleep( sleepTime );
        }
        catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

MyTextureView doRender() method:

public void doRender() {
    doubleBufferCanvas.drawPaint(Colors.BLACK);
    doDraw(doubleBufferCanvas); //draws content onto secondary canvas

        Canvas c = lockCanvas();
        c.drawPaint(Colors.BLACK);
        c.save();
        c.drawBitmap(dbbmp, 0, 0, null);
        c.restore();
        unlockCanvasAndPost(c);
}