1

我遇到了加载动画(从左到右移动 5 个连续点)在 ICS 后设备中不起作用但在 ICS 前设备中完美运行的问题。我试图复制在两者中调用动画的相同方法,但它似乎不起作用。

预先感谢,

阿曼尼·斯旺

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        int version = android.os.Build.VERSION.SDK_INT;
        tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);

        handler = new XmlParserHandlerFinal();
        handler.setContext(this.getBaseContext());
        getImpVariablesForQuery();

        if (version < VERSION_CODES.ICE_CREAM_SANDWICH) {

            try {
                // updating layout initially has updating text with 1 dot in the
                // xml
                setContentView(R.layout.updating);
                // This image view has the updating text to be progressively
                // updated
                // with dots addition
                ImageView loading = (ImageView) findViewById(R.id.loading_empty1);

                // Set updating button to drawable animation
                loading.setBackgroundResource(R.drawable.updating1);
                loadingAnimation = (AnimationDrawable) loading.getBackground();

                ImageView loading2 = (ImageView) findViewById(R.id.loading_empty2);

                // Set updating button to drawable animation
                loading2.setBackgroundResource(R.drawable.updating2);
                loadingAnimation = (AnimationDrawable) loading2.getBackground();

                tasks.execute("https://dl.dropboxusercontent.com/u/31771876/GetPhoneSettings-ST-rsp-eng.xml");
                if (tasks.get() != null) {
                    stream = tasks.getInputStream();
                    Log.v("CfA", "here");

                } else if (tasks.get() == null) {
                    setContentView(R.layout.error);

                    // finish();
                    // finish();

                }

                handler.getQueryResponse(stream);

                Values = getContentValues();

            } catch (SAXException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            // Update APN table in separate thread
            new TableUpdateRequestTask().execute("");

        } else {// ICS and later versions

            startActivity(new Intent(Settings.ACTION_APN_SETTINGS));
            try {

                // updating layout initially has updating text with 1 dot in the
                // xml
                setContentView(R.layout.updating);
                // This image view has the updating text to be progressively
                // updated
                // with dots addition
                ImageView loading = (ImageView) findViewById(R.id.loading_empty1);

                // Set updating button to drawable animation
                loading.setBackgroundResource(R.drawable.updating1);
                loadingAnimation = (AnimationDrawable) loading.getBackground();

                ImageView loading2 = (ImageView) findViewById(R.id.loading_empty2);

                // Set updating button to drawable animation
                loading2.setBackgroundResource(R.drawable.updating2);
                loadingAnimation = (AnimationDrawable) loading2.getBackground();


                setContentView(R.layout.updating);



                /*
                 * DataInputStream in = new DataInputStream(stream);
                 * BufferedReader br = new BufferedReader(new
                 * InputStreamReader(in)); String strLine; while ((strLine =
                 * br.readLine()) != null) { // Print the content on the console
                 * System.out.println (strLine); in.close(); }
                 */

            //finish();
            new TableUpdateRequestTask().execute("");
            handler.getQueryResponse(stream);

            Values = getContentValues();
            showNotification();
        } catch (SAXException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();

            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        }
    }

    private ContentValues getContentValues() {
        ContentValues values = new ContentValues();

        nameArr = handler.getnameArr();
        ApnArr = handler.getApnArr();
        mmscArr = handler.getMMSCArr();
        mmsproxyArr = handler.getMmscProxyArr();
        mmsportArr = handler.getMmsPortArr();
        proxyArr = handler.getMmscProxyArr();

        portArr = handler.getMmsPortArr();
        count = handler.getCount();
        System.out.println("count" + count);
        values.put("name", nameArr.get(i));
        values.put("apn", ApnArr.get(i));
        values.put("mmsc", mmscArr.get(i));
        values.put("mmsproxy", mmsproxyArr.get(i));
        values.put("mmsport", mmsportArr.get(i));
        values.put("proxy", proxyArr.get(i));
        values.put("port", portArr.get(i));
        if ((tm.getSimOperator()).equals(getString(R.string.numeric_tmo))) {
            values.put("numeric", getString(R.string.numeric_tmo));
            values.put("mnc", (getString(R.string.mnc_tmo)));
        } else if ((tm.getSimOperator())
                .equals(getString(R.string.numeric_att))) {
            values.put("numeric", getString(R.string.numeric_att));
            values.put("mnc", (getString(R.string.mnc_att)));
        }

        return values;
    }

    private void getImpVariablesForQuery() {

        // to get MDN
        Integer MDN = Integer.parseInt(tm.getSimOperator());
        Log.d("MDN", MDN.toString());
        mdn1 = MDN % 1234;
        Log.d("mdn1", mdn1.toString());
        mdn2 = MDN / 1234;
        Log.d("mdn2", mdn2.toString());
        // to retrieve ICCID number of the SIM

        String ICCID = tm.getSimSerialNumber();

        Log.d("ICCID", ICCID);

        long d = 1234;
        BigInteger divisor = BigInteger.valueOf(d);
        BigInteger bInteger = new BigInteger(ICCID);

        id = bInteger.divideAndRemainder(divisor);
        id1 = id[1];
        System.out.println("ICCID%1234 = " + id1);
        id2 = id[0];
        System.out.println("ICCID/1234 = " + id2);
        // Check for the Carrier Type
        if ((tm.getSimOperator()).equals(getString(R.string.numeric_tmo))) {
            car = "TMO";
        } else if ((tm.getSimOperator())
                .equals(getString(R.string.numeric_att))) {
            car = "ATT";
        }

    }

    @SuppressWarnings("unused")
    public ContentValues generateTFConfig() throws IOException, SAXException,
            ParserConfigurationException {
        // Extract the IMSI from the TelephonyManager instance
        // String imsi = tm.getSubscriberId();
        String operator = tm.getSimOperator();
        ContentValues values = new ContentValues();
        // Query the carrier table for the current data settings
        Cursor c = getContentResolver().query(APN_TABLE_URI, null, "current=?",
                new String[] { "1" }, null);
        values = copyRecordFields(c);
        // Copy the Simple Mobile settings into values
        /*
         * query the server for the data settings put the returned data settings
         * into values
         */

        String charset = "UTF-8";
        String Append_URL = "settingsquery?";
        String param1 = "mdn1=";
        String param2 = "&mdn2=";
        String param3 = "&car=";
        String param4 = "&id1=";
        String param5 = "&id2=";
        String URL = "";
        String parameters = param1 + mdn1 + param2 + mdn2 + param3 + car
                + param4 + id1 + param5 + id2;
        URL = Base_URL + Append_URL + parameters;
        Log.i("url...", URL);
        new NetworkTask().execute(URL);

        // if (handler.getQueryResult().equals("success")) { values.put("mmsc",
        // handler.getMMSCArr());

        // handler.getMmscProxyArr(); values.put("mcc",
        // getString(R.string.mcc));
        // if ((tm.getSimOperator()).equals(getString(R.string.numeric_tmo))) {
        // values.put("numeric", getString(R.string.numeric_tmo));
        // values.put("mnc", (getString(R.string.mnc_tmo))); } else if
        // ((tm.getSimOperator()) .equals(getString(R.string.numeric_att))) {
        // values.put("numeric", getString(R.string.numeric_att));
        // values.put("mnc", (getString(R.string.mnc_att))); }

        // } else if (handler.getQueryResult().equals("no match")) {
        // showAlert("no match"); } else if
        // (handler.getQueryResult().equals("no plan")) { showAlert("no plan");
        // }

        return values;
    }

    /*
     * Insert a new APN entry into the system APN table Require an apn name, and
     * the apn address. More can be added. Return an id (_id) that is
     * automatically generated for the new apn entry.
     */
    public int InsertAPN() throws SecurityException {

        int id = -1;
        if (i < nameArr.size()) {
            for (i = 0; i < nameArr.size(); i++) {
                ContentValues values2 = new ContentValues();
                // values2 = values1;
                values2 = getValues();
                ContentResolver resolver = getContentResolver();
                Cursor c = null;
                try {
                    Uri newRow = resolver.insert(APN_TABLE_URI, values2);
                    // System.out.println("values in insertAPN" + values1);
                    if (newRow != null) {
                        c = resolver.query(newRow, null, null, null, null);
                        Log.d(TAG, "Newly added APN:");
                        // TF Settings have been inserted
                        // Obtain the apn id
                        int idindex = c.getColumnIndex("_id");
                        c.moveToFirst();
                        id = c.getShort(idindex);

                        Log.d(TAG, "New ID: " + id
                                + ": Inserting new APN succeeded!");
                    }
                } catch (SQLException e) {
                    Log.d(TAG, e.getMessage());
                }
                if (c != null)
                    c.close();
            }
        }
        return id;

    }

    public ContentValues getValues() {

        ContentValues values = new ContentValues();

        values.put("name", nameArr.get(i));
        values.put("apn", ApnArr.get(i));
        values.put("mmsc", mmscArr.get(i));
        values.put("mmsproxy", mmsproxyArr.get(i));
        values.put("mmsport", mmsportArr.get(i));
        values.put("proxy", proxyArr.get(i));
        values.put("port", portArr.get(i));
        if ((tm.getSimOperator()).equals(getString(R.string.numeric_tmo))) {
            values.put("numeric", getString(R.string.numeric_tmo));
            values.put("mnc", (getString(R.string.mnc_tmo)));
        } else if ((tm.getSimOperator())
                .equals(getString(R.string.numeric_att))) {
            values.put("numeric", getString(R.string.numeric_att));
            values.put("mnc", (getString(R.string.mnc_att)));
        }

        return values;

    }

    /*
     * Delete APN data where the indicated field has the values Entire table is
     * deleted if both field and value are null
     */
    private void DeleteAPNs(String field, String[] values)
            throws SecurityException {
        int c = 0;
        c = getContentResolver().delete(APN_TABLE_URI, null, null);
        if (c != 0) {
            String s = "APNs Deleted:\n";
            Log.d(TAG, s);

        }

    }

    /*
     * Return all column names stored in the string array
     */
    private String getAllColumnNames(String[] columnNames) {
        String s = "Column Names:\n";
        for (String t : columnNames) {
            s += t + ":\t";
        }
        return s + "\n";
    }

    /*
     * Copy all data associated with the 1st record Cursor c. Return a
     * ContentValues that contains all record data.
     */
    private ContentValues copyRecordFields(Cursor c) {
        if (c == null)
            return null;
        int row_cnt = c.getCount();
        Log.d(TAG, "Total # of records: " + row_cnt);
        ContentValues values = new ContentValues();//
        if (c.moveToFirst()) {
            String[] columnNames = c.getColumnNames();
            Log.d(TAG, getAllColumnNames(columnNames));
            String row = "";
            for (String columnIndex : columnNames) {
                int i = c.getColumnIndex(columnIndex);
                row += c.getString(i) + ":\t";
                // if (i>0)//Avoid copying the id field
                // id to be auto-generated upon record insertion
                values.put(columnIndex, c.getString(i));
            }
            row += "\n";
            Log.d(TAG, row);
            Log.d(TAG, "End Of Records");
        }
        return values;
    }

    // showAlert displays the text contained in message as an alert
    public void showAlert(String message) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(message).setPositiveButton("OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        ConfigFinalActivity.this.finish();
                    }
                });
        mErrorAlert = builder.create();
        mErrorAlert.show();
    }

    // showErrorAlert displays an alert with layout and a title
    private void showErrorAlert(int layoutRes, String title) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        // Get the layout inflater
        LayoutInflater inflater = ConfigFinalActivity.this.getLayoutInflater();

        // Inflate and set the layout for the dialog
        // Pass null as the parent view because its going in the dialog layout
        builder.setTitle(title)
                .setView(inflater.inflate(layoutRes, null))
                .setPositiveButton(getString(R.string.assisted_button),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                startActivity(new Intent(
                                        Settings.ACTION_APN_SETTINGS));
                                try {
                                    showNotification();
                                } catch (SAXException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                } catch (ParserConfigurationException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                }
                            }
                        });
        mErrorAlert = builder.create();
        mErrorAlert.show();
    }

    // showNotification starts the process of sending notifications to the bar
    // to assist the user in updating the data settings on ICS and later
    // versions of Android
    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    void showNotification() throws SAXException, ParserConfigurationException {
        // handler.getQueryResponse();

        /*
         * String charset = "UTF-8"; String Append_URL = "settingsquery?";
         * String param1 = "mdn1="; String param2 = "&mdn2="; String param3 =
         * "&car="; String param4 = "&id1="; String param5 = "&id2="; String URL
         * = ""; String parameters = param1 + mdn1 + param2 + mdn2 + param3 +
         * car + param4 + id1 + param5 + id2; URL = Base_URL + Append_URL +
         * parameters; Log.i("url...", URL); new NetworkTask().execute(URL);
         */
        String field = getString(R.string.config_name_label);

        String value = Values.get("name").toString();
        int mId = 1;
        String title = "1 of " + UpdateActivity.TotalSteps + " (Update "
                + field + ":)";
        Notification.Builder mBuilder = new Notification.Builder(this)
                .setSmallIcon(R.drawable.ic_launcher).setContentTitle(title)
                .setContentText(value);
        Intent resultIntent = new Intent(this,
                NotificationActivityForMultiProf.class);
        resultIntent.putExtra(field, value);
        PendingIntent resultPendingIntent = PendingIntent.getActivity(
                getApplicationContext(), 0, resultIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        mBuilder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        // mId allows you to update the notification later on.
        mNotification = mBuilder.getNotification();
        mNotification.flags |= Notification.FLAG_AUTO_CANCEL;
        mNotificationManager.notify(mId, mNotification);
        finish();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        // TODO Auto-generated method stub
        super.onSaveInstanceState(outState);
        if (mNotification != null) {
            outState.putString("NOTIFICATIONB", mNotification.toString());
        }
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        if (mErrorAlert != null)
            mErrorAlert.dismiss();
    }

    public void onClick(View v) {
        if (v == mXButton) {
            finish();
        }
    }

    // This thread performs the setting update and shows pseudo progress update
    private class TableUpdateRequestTask extends
            AsyncTask<String, Integer, String> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            //
        }

        @Override
        protected String doInBackground(String... params) {
            int result = 0;

            try {
                result = updateTable();
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }// Settings updated with this atomic call
            catch (SAXException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ParserConfigurationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            // The code below plays a ST Promo animation
            // prior to displaying update success or failure message
            for (int incr = 0; incr < 2; incr++) {
                // Sleep for 1/2 second
                // Invoke UI to change updating text to show 1 dot
                // And Increasing the level to reduce the amount of clipping and
                // slowly reveals the hand image
                publishProgress(R.drawable.loading_full,
                        R.drawable.loading_empty, R.drawable.loading_empty,
                        R.drawable.loading_empty, R.drawable.loading_empty);
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    Log.d(TAG, "sleep failure");
                }
                publishProgress(R.drawable.loading_full,
                        R.drawable.loading_full, R.drawable.loading_empty,
                        R.drawable.loading_empty, R.drawable.loading_empty);
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    Log.d(TAG, "sleep failure");
                }
                publishProgress(R.drawable.loading_full,
                        R.drawable.loading_full, R.drawable.loading_full,
                        R.drawable.loading_empty, R.drawable.loading_empty);
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    Log.d(TAG, "sleep failure");
                }
                publishProgress(R.drawable.loading_full,
                        R.drawable.loading_full, R.drawable.loading_full,
                        R.drawable.loading_full, R.drawable.loading_empty);
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    Log.d(TAG, "sleep failure");
                }
                publishProgress(R.drawable.loading_full,
                        R.drawable.loading_full, R.drawable.loading_full,
                        R.drawable.loading_full, R.drawable.loading_full);

                // Sleep for 1/2 second
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    Log.d(TAG, "sleep failure");
                }
            }
            if (result != -1)
                return "success";
            else
                return "failure";
        }

        @Override
        protected void onPostExecute(String result) {
            // TODO Auto-generated method stub
            super.onPostExecute(result);
            // Show updated screen if table was successfully updated
            // Or alert indicating settings are not updated
            if (result.equals("success")) {
                completeUpdate();
            } else
                setContentView(R.layout.error);

        }

        // Framework UI thread method corresponding to publishProgress call in
        // worker thread
        protected void onProgressUpdate(Integer... progress) {
            // Call function to update image view
            setProgressImgView(progress[0], progress[1], progress[2],
                    progress[3], progress[4]);
        }

    }

    private int updateTable() throws IOException, SAXException,
            ParserConfigurationException {
        int insertResult = -1;// returned value if table is not properly updated
        try {
            ContentValues TFCarrierTableEntry = generateTFConfig();
            // ContentValues TFCarrierTableEntry2 = generateTFConfig();
            // Replace T-Mo Data settings if there is no SIM or SM/T-Mo SIM is
            // present
            if (tm.getSimState() == TelephonyManager.SIM_STATE_ABSENT
                    || (tm.getSimOperator())
                            .equals(getString(R.string.numeric_tmo))) {

                // delete all APNs before adding new APNs
                DeleteAPNs("numeric=?",
                        new String[] { getString(R.string.numeric_tmo) });
                // Insert NET10 Data Settings into Carrier table

                insertResult = InsertAPN();

            } else if (tm.getSimState() == TelephonyManager.SIM_STATE_ABSENT
                    || (tm.getSimOperator())
                            .equals(getString(R.string.numeric_att))) {
                // Delete all APNs before adding new APNs
                DeleteAPNs("numeric=?",
                        new String[] { getString(R.string.numeric_att) });
                // Insert NET10 Data Settings into Carrier table

                insertResult = InsertAPN();

            } else
                // non SM/ non T-Mo SIM
                showAlert(getString(R.string.insert_sm_dialog));
        } catch (SecurityException e) {
            showErrorAlert(R.layout.assisted_setting,
                    getString(R.string.assited_title));
            Log.d(TAG, e.getMessage());
        }
        return insertResult;
    }

    private void completeUpdate() {
        // Displaying final layout after pre-ICS automatic settings update
        setContentView(R.layout.completion);
        mXButton = (Button) findViewById(R.id.x_button);
        mXButton.setOnClickListener(this);
    }

    // This function return a cursor to the table holding the
    // the APN configurations (Carrier table)
    public Cursor getConfigTableCursor() {
        return getContentResolver()
                .query(APN_TABLE_URI, null, null, null, null);
    }

    public ArrayList<String> getnameArr() {

        return nameArr;
    }

    public ArrayList<String> getApnArr() {

        return ApnArr;
    }

    public ArrayList<String> getMMSCArr() {

        return mmscArr;
    }

    public ArrayList<String> getMmscProxyArr() {

        return mmsproxyArr;
    }

    public ArrayList<String> getMmsPortArr() {

        return mmsportArr;
    }

    public int getCount() {
        return count;
    }

    public ArrayList<String> getProxyArr() {

        return proxyArr;
    }

    public ArrayList<String> getPortArr() {

        return portArr;
    }

    private void setProgressImgView(Integer imgViewId1, Integer imgViewId2,
            Integer imgViewId3, Integer imgViewId4, Integer imgViewId5) {
        // update image view with the updating dots
        // Reset view layout in case orientation while updating
        setContentView(R.layout.updating);
        mProgressImageview1 = (ImageView) findViewById(R.id.loading_empty1);
        mProgressImageview2 = (ImageView) findViewById(R.id.loading_empty2);
        mProgressImageview3 = (ImageView) findViewById(R.id.loading_empty3);
        mProgressImageview4 = (ImageView) findViewById(R.id.loading_empty4);
        mProgressImageview5 = (ImageView) findViewById(R.id.loading_empty5);
        mProgressImageview1.setImageResource(imgViewId1);
        mProgressImageview2.setImageResource(imgViewId2);
        mProgressImageview3.setImageResource(imgViewId3);
        mProgressImageview4.setImageResource(imgViewId4);
        mProgressImageview5.setImageResource(imgViewId5);
        // mLoadingCircle = (ImageView) findViewById(R.id.loading_empty);

    }

    class NetworkTask extends AsyncTask<String, String, InputStream> {
        private static final String LOG_TAG = "STDataSettings";
        private static final String TAG_RESULT = "success";
        private InputStream stream;

        @Override
        protected InputStream doInBackground(String... params) {
            Bundle queryResults = null;

            String urlQueryString = params[0];

            try {
                stream = getQueryResults("https://dl.dropboxusercontent.com/u/646464/GetPhoneSettings-ST-rsp-eng.xml");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SAXException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            return stream;
        }

        /*
         * Sends a query to server and gets back the parsed results in a bundle
         * urlQueryString - URL for calling the webservice
         */
        protected synchronized InputStream getQueryResults(String urlQueryString)
                throws IOException, SAXException, SSLException,
                SocketTimeoutException, Exception {
            // HttpsURLConnection https = null;
            Bundle queryResults = new Bundle();

            HttpsURLConnection https = null;
            String uri = urlQueryString;
            // URL urlo = new URL(urlQueryString);
            URL urlo = new URL(uri);

            https = (HttpsURLConnection) urlo.openConnection();
            https.setConnectTimeout(50000); // 20 second timeout
            https.setRequestProperty("Connection", "Keep-Alive");
            try {
                https = (HttpsURLConnection) urlo.openConnection();
                // https.setConnectTimeout(20000); //20 second timeout
                // connection.setRequestMethod("GET");
                // connection.connect();

                // xmlStream = new BufferedInputStream(https.getInputStream());

                if ("gzip".equals(https.getContentEncoding())) {
                    stream = new GZIPInputStream(stream);
                } else
                    stream = https.getInputStream();

                // stream = new BufferedInputStream(https.getInputStream());
                /*
                 * DataInputStream in = new DataInputStream(stream);
                 * BufferedReader br = new BufferedReader(new
                 * InputStreamReader(in)); String strLine; while ((strLine =
                 * br.readLine()) != null) { // Print the content on the console
                 * System.out.println (strLine); in.close(); }
                 */
            } catch (SSLException e) {
                Log.e(LOG_TAG, e.toString());
                e.printStackTrace();

            } catch (SocketTimeoutException e) {
                Log.e(LOG_TAG, e.toString());
                e.printStackTrace();
            } catch (IOException e) {
                Log.e(LOG_TAG, e.toString());
                e.printStackTrace();

            } catch (Exception e) {
                Log.e(LOG_TAG, e.toString());
                e.printStackTrace();

            } finally {
                // https.disconnect();
            }
            // String queryResult = handler.getQueryResponse(stream );
            String queryResult = null;
            queryResults.putString(TAG_RESULT, queryResult);
            /*
             * if (queryResult.equals("success")) {
             * queryResults.putString("Name", handler.getName());
             * queryResults.putString("APN", handler.getApn());
             * queryResults.putString("MMSC", handler.getMMSC());
             * queryResults.putString
             * ("Proxy_address",handler.getProxyAddress());
             * queryResults.putString("Proxy_Port",handler.getProxyPort());
             * queryResults
             * .putString("MMSC_Proxy_address",handler.getMMSCProxyAddress());
             * queryResults
             * .putString("MMSC_Proxy_address",handler.getMMSCProxyPort()); }
             */
            // XmlParserHandlerFinal handler = new XmlParserHandlerFinal();
            // handler.getQueryResponse(xmlStream );

            return stream;
        }

        public InputStream getInputStream() {
            return stream;
        }

        @Override
        protected void onPostExecute(InputStream stream) {

        }
    }
}

更新1.xml:

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"    
    android:oneshot="false">    
    <item android:drawable="@drawable/loading_empty" android:duration="500" />    
    <item android:drawable="@drawable/loading_full" android:duration="500" />    
</animation-list>
4

1 回答 1

0

来自http://developer.android.com/guide/topics/resources/animation-resource.html#Frame 的开发人员文档
该示例显示了start()对动画方法的调用。

ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image);
rocketImage.setBackgroundResource(R.drawable.rocket_thrust);

rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
rocketAnimation.start(); // <--------- Does no harm to PRE ICS devices 

如果您要针对各种 droid 版本(包括 JB),为什么不调用这个方法呢?

于 2013-08-06T15:54:54.190 回答