Affichage des articles dont le libellé est Active questions tagged android - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Active questions tagged android - Stack Overflow. Afficher tous les articles

mardi 4 août 2015

implementing onitemclicklistener with GridView

I have a grid view with custom adapter that contains an image and a TextView holder. The objective is to change color matrix of ImageView with onclick and then use an itemclicklistener to perform another action

here is the clicklistener in adapter

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View vi = convertView;
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if(convertView == null){
        vi = inflater.inflate(R.layout.pages_grid,  null);

        if (imageLoader == null)
            imageLoader = AppController.getInstance().getImageLoader();

        final NetworkImageView page_pic = (NetworkImageView) vi.findViewById(R.id.grid_icon);
        TextView page_name = (TextView) vi.findViewById(R.id.page_selected);
        final RelativeLayout rl = (RelativeLayout) vi.findViewById(R.id.selected_bar);
        LinearLayout container = (LinearLayout) vi.findViewById(R.id.page_container);
         ColorMatrix matrix = new ColorMatrix();
            matrix.setSaturation(0);

            final ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
            page_pic.setColorFilter(filter);    
        HashMap<String, String> pages = getItem(position);

        page_pic.setImageUrl("http://ift.tt/wljqS4" + pages.get("page_id") + "/picture", imageLoader);
        page_name.setText(pages.get("page_name"));
        container.setOnClickListener(new OnClickListener() {
            private boolean isSelected = false;
            @Override
            public void onClick(View v) {
                if(isSelected == false){
                    page_pic.setColorFilter(null);
                    rl.setBackgroundColor(context.getResources().getColor(R.color.cyan));
                    isSelected = true;
                }else{
                    page_pic.setColorFilter(filter);
                    rl.setBackgroundColor(Color.parseColor("#f0CCCCCC"));
                    isSelected = false;
                }

            }
        });
    }
    return vi;
}

and here is the on itemclicklistener

gv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {


            String page_id = data.get(position).get("page_id");
            if(pages.contains(page_id))
                {
                pages.remove(page_id);
                }else{              
            pages.add(page_id);
                }
            Toast.makeText(getApplicationContext(),  "" + pages.toString(), Toast.LENGTH_SHORT).show();

        }
    });

when I click the color matrix is applied but toast is not shown and when I comment the clicklistener in adapter the toast is shown. but I want the 2 click actions to be triggered when I click the item

save images in sd card from server in Android

I want to download images from server and save into sd card in Emulator.First i have to get json string of images and passing to the download server url for download and save into sd card. I m getting error of nullPointer exception at the run time.Please someone help me how to do this.

Here is my Code

public void getAllImagePath_List() {
        String strUrl_GetAll_Activity = "http://xxx/xxx/xxx.svc/xxx/xx/"+str_UserId+"/xx/"+xxx+"/xxx/"+xxx;
        Log.e("strUrl_GetAll_Activity ", " = " + strUrl_GetAll_Activity);
        InputStream inputStream = null;

        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpResponse httpResponse = httpclient.execute(new HttpGet(strUrl_GetAll_Activity));
            inputStream = httpResponse.getEntity().getContent();

            if (inputStream != null)
                strResult = convertInputStreamToString(inputStream);
            else
                strResult = "Did not work!";

            String jsonStr = strResult;

            try {

                JSONObject jsonObj = new JSONObject(jsonStr);
                String jsonResult = jsonObj.toString().trim();
                Log.e("jsonResult ", " = " + jsonResult);

                JSONObject getAllActivity_List = jsonObj.getJSONObject("Get_ALL_ActivityListResult");
                Log.e("getAllActivity_List ", " = " + getAllActivity_List.toString());

                String strSync = getAllActivity_List.getString("Sync_Time");
                Log.e("strSync ", " = " + strSync.toString());

                JSONArray jarr = getAllActivity_List.getJSONArray("ActivityObjectList");
                Log.e("jarr ", " = " + jarr.toString());

                SQLiteDatabase mDb = dbhelper.getWritableDatabase();
                int imageNum = 0;
                BufferedOutputStream bos;
                 imagesArray = new String[jarr.length()];
                for (int j = 0; j < jarr.length(); j++)
                {
                    JSONObject jobjVessels = jarr.getJSONObject(j);

                    str_imgList_imageaudioPath = jobjVessels.getString("imageaudioPath");
                    Log.e("", "" + str_imgList_imageaudioPath);


                    String str_ImageUrl = "http://xxx/xxx/xxx.svc/DownloadFile/FileName/"+str_imgList_imageaudioPath;
                    downloadUrl(str_ImageUrl);

                    Log.e("Downloaded Completed","!!!!!");

                }

            }

            catch (JSONException je)
            {
                je.printStackTrace();
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    private Bitmap downloadUrl(String strUrl) throws IOException{
        Bitmap bitmap=null;
        InputStream iStream = null;
        try{
            URL url = new URL(strUrl);
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            urlConnection.connect();
            iStream = urlConnection.getInputStream();
            bitmap = BitmapFactory.decodeStream(iStream);
            Log.e("bitmap while  url", "downloading " + bitmap.toString());



            saveBitmap(bitmap);
        }catch(Exception e){
            Log.e("Exception while  url", "downloading " + e.toString());
        }finally{
            iStream.close();
        }

        return bitmap;
    }


    public void saveBitmap(Bitmap bm)
    {
        try
        {
            String mBaseFolderPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/json_imglist";
            String mFilePath = mBaseFolderPath + "abcd.jpg";

            FileOutputStream stream = new FileOutputStream(mFilePath);
            bm.compress(Bitmap.CompressFormat.JPEG, 100, stream);
            stream.flush();
            stream.close();
        }
        catch(Exception e)
        {
            Log.e("Could not save", e.toString());
        }
    }

Thanks to appreciate.

Ionic android build failed after added AdMob Pro

I just started to use ionic framework to build android apps. So I've run:

ionic start App blank
ionic platform add android
ionic build android
ionic run android

So far so good, I can test my app in my android phone with no problem. Now I want to add admob to my app. I decided to use the AdMobPro, so I did this:

ionic plugin add cordova-plugin-admobpro

The plugin added successfully. Without having implemented the admobpro code in my app.js, I tried to run ionic build android again just to make sure everything is ok, I got this error:

Running: /home/vagrant/app/android-quotes/platforms/android/gradlew cdvBuildDebug -b /home/vagrant/app/android-quotes/platforms/android/build.gradle -
Dorg.gradle.daemon=true

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not find any version that matches com.google.android.gms:play-services-ads:+.
     Searched in the following locations:
         http://ift.tt/1fhRit3
         http://ift.tt/1MMeoCs
     Required by:
         :android:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 11.603 secs

/home/vagrant/app/android-quotes/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /home/vagrant/app/android-quotes/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/vagrant/app/android-quotes/plat
forms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /home/vagrant/app/android-quotes/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /home/vagrant/app/android-quotes/platforms/android/cordova/build: Command failed with exit code 1
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

Anyone has this error before?

Can't correctly release PowerManager.WakeLock

I'm using PowerManager.WakeLock for Sensor.TYPE_LIGHT in Activity. It works well but when i'm closing/went to other Activity SensorEventListener keep turn on/off screen if get sensor changes.

Code sample

    SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    Sensor mLightSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock mWakeLock = mPowerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "tag");

SensorEventListener interface method

@Override
public void onSensorChanged(SensorEvent event) {
    float[] lux = event.values;

    if (lux[0] <= 200) {
        mWakeLock.acquire();
    } else {
        if (mWakeLock.isHeld()) {
            mWakeLock.release();
        }
    }
}

SensorManager listener

 @Override
protected void onResume() {
    super.onResume();
    mSensorManager.registerListener(this, mLightSensor, SensorManager.SENSOR_DELAY_FASTEST);

}

@Override
protected void onPause() {
    super.onPause();
    mSensorManager.unregisterListener(this, mLightSensor);

}

@Override
protected void onDestroy() {
    super.onDestroy();
    if (mWakeLock.isHeld()) {
        mWakeLock.release();
    }

}

So how to correctly release and disable WakeLock. Thanks in advance.

Transparent Listview over google Map android

In my application I need to create a transparent listview over google map. I am using toggle button to open and close listview. When listview is visible it should be transparent so that google map should be visible/semi-visible.

For this part there are three layouts. 1. custom_cluster_mapview.xml 2. bottomlayout.xml 3. map_list_view_row

  1. custom_cluster_mapview.xml

    <RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    xmlns:ads="http://ift.tt/GEGVYd"
    xmlns:materialdesign="http://ift.tt/1ImoBTp"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".map.MapView" >
    
    <LinearLayout
        android:id="@+id/myLinearLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <LinearLayout
            android:id="@+id/mapLayout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" >
    
            <fragment
                android:id="@+id/mycustomemap"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                class="com.google.android.gms.maps.SupportMapFragment" />
        </LinearLayout>
    
        <include layout="@layout/bottomlayout" />
    
    
    
    
    </LinearLayout>
    
    </RelativeLayout>
    
    
  2. bottomlayout.xml

       <LinearLayout
        xmlns:android="http://ift.tt/nIICcg"
    
        android:id="@+id/outerLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:weightSum="2"
        android:orientation="vertical"
        >
    
    
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                >
            <ToggleButton
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:background="@drawable/up_arrow"
                android:textOff=""
                android:textOn=""
                android:id="@+id/toggleButtonListView"
                android:layout_gravity="center_horizontal" />
            </LinearLayout>
    
        <LinearLayout
            android:id="@+id/mapListViewSlider"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone"
            android:layout_weight="1.95"
            android:orientation="vertical">
    
    
            <CheckBox
                android:id="@+id/sort_distance"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Sort By Distance"/>
            <ListView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:dividerHeight="5dp"
                android:divider="@color/red"
                android:id="@+id/map_listview"/>
            </LinearLayout>
    
    </LinearLayout>
    
    

3. map_list_view_row.xml

    <RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="10dp"
    android:paddingBottom="12dp">


    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginLeft="10dp"
        android:weightSum="4"
        android:id="@+id/linearLayout">
        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1">
            <TextView
                android:id="@+id/map_list_view_tv1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:text="@string/label_name" />

            <TextView
                android:id="@+id/map_list_view_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/map_list_view_tv1"
                android:text="abcde"/>
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1">

            <TextView
                android:id="@+id/map_list_view_tv2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/label_category" />
            <TextView
                android:id="@+id/map_list_view_category"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/map_list_view_tv2"
                android:text="abcde" />
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1">
            <TextView
                android:id="@+id/map_list_view_tv3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/label_location" />
            <TextView
                android:id="@+id/map_list_view_location"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/map_list_view_tv3"
                android:text="abcde" />
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1">

            <TextView
                android:id="@+id/map_list_view_tv4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_marginBottom="10dp"
                android:text="@string/label_distance" />

            <TextView
                android:id="@+id/map_list_view_distance"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/map_list_view_tv4"
                android:text="abcde" />

        </RelativeLayout>
    </LinearLayout>
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/map_list_view_imageView"
        android:background="@drawable/med"
        android:layout_marginTop="4dp"
        android:layout_marginRight="16dp"
        android:layout_alignParentRight="true"/>

</RelativeLayout>

Following is the picture when map is loaded http://ift.tt/1MJHjKT

At bottom of the screen there is up arrow button. I want to make background of that transparent. So that only arrow is visible without any background. When I click on the arrow listView is shown. Like below

http://ift.tt/1Imozuw

How to make listView transparent so that the google map is visible/semi-visible.

Thanks in advance.

Android studio - cant find my app on device after building

I'm using android studio 1.3 , I'm running/debugging my app on my Nexus 5 - works great but after exiting the app - I cant find my app on the device.. so actually every time I want to run it I need to connect my device to the studio and run...

It happened suddenly , in the past I ran the program and it did! Stay on the device Tried on different devices.

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "app.meantneat.com.meetneat"
        minSdkVersion 17
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()

    maven {
        url 'http://ift.tt/1CLc08h'
    }
}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services:7.3.0'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    //compile 'com.getbase:floatingactionbutton:1.9.0'
    //compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.melnykov:floatingactionbutton:1.3.0'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'me.villani.lorenzo.android:android-cropimage:1.1.0'
    compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'




    //compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    //compile 'com.google.android.gms:play-services:7.3.0'
}

Any help would be greatly appreciated.Thanks, Dan

Getting a NPE with AppCompatActivity that I wasn't getting with ABS

In my onCreateOptionsMenu() I'm getting a View v that is ending up null. I can put a null check around it, but it won't actually solve the issue since I need to use that view further on in the method. The code causing v to be null is below:

 @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);


        /** Create an option menu from res/menu/items.xml */
        getMenuInflater().inflate(R.menu.dee, menu);
        View v = (View) menu.findItem(R.id.search_menu_item).getActionView();

Any reason why seemingly changing the Activity to use AppCompat instead of ABS is causing a null pointer?

Android Blur View (Blur background behind the view)

I am trying to make the bottom part of an Image blur for the view on top it like in the image.

I tried blurring it using Rendenscript but I am not able to blur only the part behind the view. :(

I have seen many libraries but almost all of them blur the entire image, but not a part of it.

Also, an important part is that I am using this inside a ViewPager and hence needs to be fast and dynamic something like this in IOS which redraws itself the moment image behind it changes.

Any help is appreciated. Thanks for stopping by!

My xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/image"
        android:src="@drawable/broadstairs"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:layout_centerInParent="true"/>

    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:text="Hello World"
        android:gravity="center"
        android:layout_alignParentBottom="true"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        android:textSize="36sp"/>
</RelativeLayout>

My code:

BlurBuilder.java

public class BlurBuilder {
    private static final float BITMAP_SCALE = 0.1f;
    private static final float BLUR_RADIUS = 7.5f;

    public static Bitmap blur(Context context, Bitmap image) {
        int width = Math.round(image.getWidth() * BITMAP_SCALE);
        int height = Math.round(image.getHeight() * BITMAP_SCALE);

        Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
        Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);

        RenderScript rs = RenderScript.create(context);
        ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
        Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
        Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
        theIntrinsic.setRadius(BLUR_RADIUS);
        theIntrinsic.setInput(tmpIn);
        theIntrinsic.forEach(tmpOut);
        tmpOut.copyTo(outputBitmap);

        return outputBitmap;
    }

    @SuppressLint("NewApi")
    public static void blur(final Context context, final Bitmap bitmap, final View view) {

        new AsyncTask<Void, Void, Bitmap>() {

            @Override
            protected Bitmap doInBackground(Void... params) {
                Paint paint = new Paint();
                paint.setFilterBitmap(true);
                Bitmap cropImage = Bitmap.createBitmap(bitmap, 0, bitmap.getHeight() - view.getHeight(), bitmap.getWidth(), view.getHeight());

                return BlurBuilder.blur(context, cropImage);
            }


            @Override
            protected void onPostExecute(Bitmap bitmap) {
                super.onPostExecute(bitmap);
                if (bitmap != null) {
                    int sdk = android.os.Build.VERSION.SDK_INT;
                    if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                        view.setBackgroundDrawable(new BitmapDrawable(context.getResources(), bitmap));
                    } else {
                        view.setBackground(new BitmapDrawable(context.getResources(), bitmap));
                    }

                }

            }
        }.execute();


    }

}

In my MainActivity's onCreate I do:

BlurBuilder.blur(BitmapActivity.this, ((BitmapDrawable) mView.getDrawable()).getBitmap(), mDummyView);

Below is the result:

enter image description here

Android: MediaRecorder start failed

I run my video recorder app on 30 type of phones are fine except for Samsung GT-I9082i. My app display the camera info. on a OpenGL view but not surface view. If I use surface view to dispaly the camera info. on GT-I9082i, all are OK. Because I must to render more efffects use opengl,I cann't use Surface view.

if (mMediaRecorder == null) {
            mMediaRecorder = new MediaRecorder();
        } else {
            mMediaRecorder.reset();
        }

mMediaRecorder.setCamera(camera);

        // Step 2: Set sources

        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);

        mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

// Step 4: Set a CamcorderProfile (requires API Level 8 or higher)

        mMediaRecorder.setProfile(CamcorderProfile.get(cameraIndex, CamcorderProfile.QUALITY_HIGH));

mRecAudioFile = File.createTempFile("Video", ".mp4", mRecVedioPath);

mMediaRecorder.setOutputFile(mRecAudioFile.getAbsolutePath());

        // Step 6: Set the preview output

        mMediaRecorder.setPreviewDisplay(null);

        // Step 7: Set Video Size


        mMediaRecorder.setVideoSize(cameraVideoOptimalSize.width, cameraVideoOptimalSize.height);

// Step 8: Prepare configured MediaRecorder

        try {
            mMediaRecorder.prepare();
            mMediaRecorder.start();

        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

Android how to use Toolbar in ListActivity?

I have activity as

 public class NoteListActivity extends ListActivity{
 }

I don't have following method available any more:-

    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

How to use ListActivity and android.support.v7.widget.Toolbar ?

Git - Android Studio no longer lets me commit changes and push to GitHub

As of a couple of hours ago, Android Studio no longer lets me commit my changes. When the Commit dialog pops up, it shows the files that have changed and lets me enter a commit message. However, when i click Commit (or Commit and Push), the progress dialog comes up, goes to about 10% - 20% and then just disappears without actually committing anything. If i try again (without restarting the IDE first), nothing seems to happen at all when i click Commit/Commit and Push.

Sadly, Google searches have so far not been very helpful to me, so if any of you could help me out, i would really appreciate it.

I have heard, however, that git might sometimes clash with Windows on changing the capitalization of file names. I do remember renaming my Utilities package to utilities and Adapters package to adapters. Could this be causing my problem and if so, how can i fix this?

Thanks in advance.

How to disable notification bar with overlay or another method for android application

I want to disable notification bar in android. When we slide our finger up to down, I want to disable notification bar.

How to format time from Android's TimePicker?

Hi I am currently using a TimePickerDialog to set the time and display it into a text view. However, I am having problems with the formating. This is my code

    TimePickerDialog.OnTimeSetListener time = new TimePickerDialog.OnTimeSetListener() {
    @Override
    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
        if ((hourOfDay >= 1) && (hourOfDay <= 11.59)) {
            hours = hourOfDay;
            am_pm = "AM";
        } else if (hourOfDay >= 12) {
            hours = hourOfDay - 12;
            am_pm = "PM";
        } else if (hourOfDay == 0) {
            hours = 12;
            am_pm = "AM";
        }

        tvScheduleTime.setText(hours + " : " + minute + " " + am_pm);

    }
};

This method works in retrieving AM and PM but the numbering is weird, like 6:08 AM becomes 6:8 AM. How can I make it so that it creates the text HH-MM AM/PM?

android.support.design.widget.coordinatorlayout not found in eclipse

I am using eclips and when i am running my project i got the following error .

08-04 17:12:25.596: E/AndroidRuntime(4175): FATAL EXCEPTION: main
08-04 17:12:25.596: E/AndroidRuntime(4175): java.lang.RuntimeException: Unable to start activity ComponentInfo{me.declangao.wordpressreader/me.declangao.wordpressreader.app.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.os.Looper.loop(Looper.java:137)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread.main(ActivityThread.java:5103)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at java.lang.reflect.Method.invokeNative(Native Method)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at java.lang.reflect.Method.invoke(Method.java:525)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at dalvik.system.NativeStart.main(Native Method)
08-04 17:12:25.596: E/AndroidRuntime(4175): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.view.LayoutInflater.createView(LayoutInflater.java:620)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at me.declangao.wordpressreader.app.PostFragment.onCreateView(PostFragment.java:72)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.Activity.performStart(Activity.java:5143)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
08-04 17:12:25.596: E/AndroidRuntime(4175):     ... 11 more
08-04 17:12:25.596: E/AndroidRuntime(4175): Caused by: java.lang.reflect.InvocationTargetException
08-04 17:12:25.596: E/AndroidRuntime(4175):     at java.lang.reflect.Constructor.constructNative(Native Method)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.view.LayoutInflater.createView(LayoutInflater.java:594)
08-04 17:12:25.596: E/AndroidRuntime(4175):     ... 24 more
08-04 17:12:25.596: E/AndroidRuntime(4175): Caused by: java.lang.NoClassDefFoundError: android.support.design.R$styleable
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.design.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:168)
08-04 17:12:25.596: E/AndroidRuntime(4175):     at android.support.design.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:162)

How to save android canvas as svg?

Is there any possible way to save the android canvas as svg. I know how to save it as png/jpeg. Im currently saving it as jpeg. Here is the code that I use now for saving.

            canvas.setDrawingCacheEnabled(true);
            canvas.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
            Bitmap bitmap = canvas.getDrawingCache();
            String path = Environment.getExternalStorageDirectory().getAbsolutePath();
            File file = new File(path+"/image.jpg");
            FileOutputStream ostream;
            try {
                file.createNewFile();
                ostream = new FileOutputStream(file);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, ostream);
                ostream.flush();
                ostream.close();
                Toast.makeText(getApplicationContext(), "image saved", Toast.LENGTH_SHORT).show();
            } catch (Exception e) {
                e.printStackTrace();
                Toast.makeText(getApplicationContext(), "error", Toast.LENGTH_SHORT).show();
            }

I want this to be saved as svg?

How to send data from android to google app engine web app made in java

I am new to google app engine and android.Made an application in android which takes value from user and post it to servlet. I used httpClient to post data from android to servlet,hosted locally and sending data from emulator . I receive null value from servlet side.I googled a lot in this context but not getting solution for the issue.Any help appreciated.Thnx

Yandex Marker's Current Latlong values in Android

I 'm not able to get the Yandex default Marker's current Latlong values in Android. What I'm really interested is to capture the current latlong values from the android mobile and yandex map marker's position is exactly what I need. Has anyone used yandex maps to get the current user location? Can you please help.

Update 1

While researching on this latlong issue with Google and Yandex, I came across a link for "GPS Fix" app from http://ift.tt/1eQ0Avl. After installing this App on the Android device and performing "Start Fixing", the latlong values now provided by Yandex SDK in my custom App is now closer to that of marker's. But still some points show over the buildings beside road (I can adjust that for now). I believe "GPS fix" app does somekind of flushing the GPS cache??? not sure if there is such a thing. I 'm still waiting for a clean solution that works without support from other app.

Thanks, Hemant

Android: Hmac SHA512 in java

I have the following code in php:

$binKey = pack("H*", $keyTest);
$hmac = strtoupper(hash_hmac($pbx_hash, $msg, $binKey));

How can i achieve the same in android (java).

I have tried few methods available for hmac sha512 but the result of php snippet is different from that of mine.

Thanks in advance

How to keep running the task even if the app is already closed?

Currently, i have built a service to do httpRequest to my php server every 15 seconds. The code works well but the problem is when i close the app the httpRequest is stop working and does not send data anymore. what i want to do is when i close the app, the httpRequest still running. what should i change in my code?

here is the code i have been working on...

public class NotificationService extends Service {

public String response;

@Override
public IBinder onBind(Intent intent) {
    return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Toast.makeText(this, "on start command", Toast.LENGTH_SHORT).show();
    new MyAsyncTask().execute("muhammad sappe");
    return START_NOT_STICKY;
}

private class MyAsyncTask extends AsyncTask<String, String, String>{

  @Override
  protected String doInBackground(String... params) {
    // TODO Auto-generated method stub
    postData(params[0]);
    return null;
  }

  @Override
  protected void onPostExecute(String result) {
      new Handler().postDelayed(new Runnable() {
            public void run() {
                new MyAsyncTask().execute("muhammad sappe");
            }
        }, 15000);
    super.onPostExecute(result);
  }

}

public void postData(String MyName){
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://mydomain/getData.php");
    try {   
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
        nameValuePairs.add(new BasicNameValuePair("action", MyName));

        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        // Execute HTTP Post Request
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        response = httpclient.execute(httppost, responseHandler);
    }catch(ClientProtocolException e){
        // TODO Auto-generated catch block
    }catch(IOException e) {
        // TODO Auto-generated catch block
    }
}

public void onDestroy() {
    super.onDestroy();
}
}

ListView first Item overlaid

My ListView displays in first Item something else as the rest of the ListView

The Problem is, that it replaces the first item instead of taking a own position.

Example how it has to be:

A (diferent to the others)

B

B

B

How it is:

A (B Overlaid by A)

B

B

As you can see, one B is missing because it is overlaid by A.

Here is the Code. I wrote my own CustomAdapter:

@Override
public int getCount() {
    if (taskItems.size() + 1 >= 0)
        return taskItems.size();
    return 0;
}

@Override
public Object getItem(int position) {
    return position;
}

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

public static class ViewHolder {
    public TextView taskTitleTextView;
    public TextView taskObjectTextView;
    public TextView taskLocationTextView;
    public ImageView taskImageImageView;

}

public static class ViewHolderProjects {
    public TextView projectTitelTextView;
    public TextView projectInfoTextView;
    public TextView projectDeadline;
    public ImageView projectImageImageView;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View vi = convertView;
    ViewHolderProjects holderProjects;
    if (position == 0) {
        if (convertView == null) {
            vi = inflater.inflate(R.layout.list_item_projects, null);
            holderProjects = new ViewHolderProjects();

            holderProjects.projectTitelTextView = (TextView) vi.findViewById(R.id.projectTitle);
            holderProjects.projectInfoTextView = (TextView) vi.findViewById(R.id.projectInfo);
            holderProjects.projectImageImageView = (ImageView) vi.findViewById(R.id.projectImage);
            holderProjects.projectDeadline = (TextView) vi.findViewById(R.id.projectdeadline);

            vi.setTag(holderProjects);
        } else {
            holderProjects = (ViewHolderProjects) vi.getTag();
        }
        if (projectMap.size() <= 0) {
            holderProjects.projectInfoTextView.setText("Keine Infos");
            holderProjects.projectTitelTextView.setText("Kein Titel");
        } else {
            if (projectMap.get(position).containsKey("project_company_image")) {
                if (projectMap.get(position).get("project_company_image").getBytes().length == 0) {
                    holderProjects.projectTitelTextView.setText(jobMap.get(position).get("job_subject"));
                    holderProjects.projectDeadline.setText(jobMap.get(position).get("job_deadline"));
                    return vi;
                }
                Bitmap bm = Bitmap.createBitmap(base64EncodeDecode.decodeBase64(projectMap.get(position).get("project_company_image")));
                holderProjects.projectTitelTextView.setText(jobMap.get(position).get("job_subject"));
                holderProjects.projectDeadline.setText(jobMap.get(position).get("job_deadline"));
                holderProjects.projectImageImageView.setImageBitmap(bm);
            }
        }
    } else {

        ViewHolder holder;
        if (convertView == null) {
            vi = inflater.inflate(R.layout.list_item_tasks, null);

            holder = new ViewHolder();
            holder.taskTitleTextView = (TextView) vi.findViewById(R.id.taskTitle);
            holder.taskObjectTextView = (TextView) vi.findViewById(R.id.taskObject);
            holder.taskLocationTextView = (TextView) vi.findViewById(R.id.taskLocation);
            holder.taskImageImageView = (ImageView) vi.findViewById(R.id.taskImage);

            vi.setTag(holder);
        } else {
            holder = (ViewHolder) vi.getTag();
        }

        if (taskItems.size() <= 0) {
            holder.taskTitleTextView.setText("Kein Titel");
            holder.taskObjectTextView.setText("Kein Objekt");
            holder.taskLocationTextView.setText("Kein Standort");
        } else {
            if (taskItems.get(position).containsKey("object_image")) {
                if (taskItems.get(position).get("object_image").getBytes().length == 0) {
                    holder.taskTitleTextView.setText(taskItems.get(position).get("task_headline"));
                    holder.taskObjectTextView.setText(taskItems.get(position).get("object_name"));
                    holder.taskLocationTextView.setText(taskItems.get(position).get("object_location"));

                    return vi;
                }
            }
            Bitmap bm = Bitmap.createBitmap(base64EncodeDecode.decodeBase64(taskItems.get(position).get("object_image")));
            holder.taskTitleTextView.setText(taskItems.get(position).get("task_headline"));
            holder.taskObjectTextView.setText(taskItems.get(position).get("object_name"));
            holder.taskLocationTextView.setText(taskItems.get(position).get("object_location"));
            holder.taskImageImageView.setImageBitmap(bm);
        }
    }
    return vi;

}