Louis-Law / cyanogen-updater

Automatically exported from code.google.com/p/cyanogen-updater
0 stars 0 forks source link

Force Close if SD card is mounted to Computer #186

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
First this is not a Bugtracker for Cyanogen-Rom Bugs. Only for the updater.
The other Bugtracker can be found here:
http://code.google.com/p/cyanogenmod/issues/list

What steps will reproduce the problem?
1. Start Updater with SD Card mounted
2.
3.

What is the expected output? What do you see instead?

Updater will force close

What ROM are you running?(including Version)

What Version of CM-Updater are you running??(When using an Experimental
one, please Provide the SVN Release Number)

Please provide a logcat of the issue:
If you get a Force close do an: adb logcat
If somethings wrong in the app do an: adb logcat cmupdater:V *:S
For older Versions of the updater: adb logcat | grep "<CM-Updater>"

Please provide any additional information below.

I have built another updater for use with another Rom developer. I am
trying to get the updater to not force close upon start up if the sd card
is not available.

This code should help but and i would like to integrate this into the
updater to bring up a dialog box saying "SD card not available. Please
Unmount SD card to contiune"

public static boolean isSdPresent() {
return
android.os.Environment.getExternalStorageState().equals(android.os.Environment.M
EDIA_MOUNTED);
}

This can check if the sd card is available and return a true or false value 

I am not a pro programmer so i am having a bit of trouble getting it
implemented. 

I figured I would post here and maybe since this will benifit the app you
can help with this. 

Thanks,
James   

Original issue reported on code.google.com by Zipste...@gmail.com on 17 May 2010 at 3:14

GoogleCodeExporter commented 8 years ago
I have found that is is crashing when trying to get preferences from the .db 
file. 

At line Opening db.

I have tried to add a get external state request and then open a dialog box but 
then
i just get a error that onCreate has not happened yet and it still force 
closes. 

I will continue to work on it and see what i come up with.

Original comment by Zipste...@gmail.com on 20 May 2010 at 1:47

GoogleCodeExporter commented 8 years ago
I went ahead and got something to work for the updater force close on start up 
if the
sd card is not available. 

In MainActivity after onCreate:

if
(android.os.Environment.getExternalStorageState().equals(android.os.Environment.
MEDIA_MOUNTED))
            {
            Log.d(TAG,"SDcard Available");
            }
        else
            {
            Log.d(TAG,"SDcard Not Available");
            LayoutInflater inflater = getLayoutInflater();
            View layout = inflater.inflate(R.layout.toast_layout,
                                           (ViewGroup) findViewById(R.id.toast_layout_root));

            ImageView image = (ImageView) layout.findViewById(R.id.image);
            image.setImageResource(R.drawable.stop);
            TextView text = (TextView) layout.findViewById(R.id.text);
            text.setText(R.string.sdcard_not_avail);

            Toast toast = new Toast(getApplicationContext());
            toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
            toast.setDuration(Toast.LENGTH_LONG);
            toast.setView(layout);
            toast.show();
            finish();
            }

and the xml file names toast_layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/toast_layout_root"
              android:orientation="horizontal"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:padding="8dp"
              android:background="@color/trans_grey"
              >
    <ImageView android:id="@+id/image"
               android:layout_width="wrap_content"
               android:layout_height="fill_parent"
               android:layout_marginRight="10dp"
               />
    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:textSize="18.0sp" 
              android:textColor="@color/white"
              />
</LinearLayout>

Of course it point to a new .png i added and also new colors in colors.xml

Hope that helps you,
James 

Original comment by Zipste...@gmail.com on 25 May 2010 at 12:34

GoogleCodeExporter commented 8 years ago
thanks. will have a look on this for the next version

Original comment by FireFart on 26 May 2010 at 4:59

GoogleCodeExporter commented 8 years ago
thx. ive implemented a check

Original comment by FireFart on 30 May 2010 at 3:36