Skip to main content

Featured

Android studio “SDK tools directory is missing”

Following 2 possible solutions will resolve this problem :  Solution1 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:" Delete your  ~/.Android*  folders (losing all of your settings :/). Run Android Studio. It will show you a welcome wizard where it tries to download the SDK again (and fails due to my rubbish internet). Click the X on the wizard window. That will enable you to get to the normal welcome dialog. Go to Settings->Project Defaults->Project Structure and change the Android SDK location to the correct one. Solution 2 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:&quo

Usage of Threads in "AddEvidenceORCarImageNotes" of my JOR Project sampleCode

//onclick for add notes done button...Thread called from Here
    public void notesDonebtn(View v)
    {
        SharedVariables.imm.hideSoftInputFromWindow(notesDoneBtn.getWindowToken(), 0);
        ps = Pattern.compile(".*\\w.*");
        ms = ps.matcher(addnotesText.getText().toString());
        bs = ms.matches();
        if(addnotesText.getText().toString().length()>0 && bs==true)
        {           
            SharedVariables.addnotesText=addnotesText.getText().toString();
            if (SharedVariables.checkInternetConnection(AddEvidenceORCarImageNotes.this)) {
                progressDialog = ProgressDialog.show(
                        AddEvidenceORCarImageNotes.this, "",
                        "Uploading Vehicle image...", true);
                try {                   
                        startThread();                   
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                showAlert(SharedVariables.internetErrorMsg);
            }
           
        }

public void startThread()
    {
        Thread backgroundthread =new Thread( new Runnable()
        {
            public void run()
            {
                //AddNotes Web service calling...
                        clsCredentials crediantials=new clsCredentials(AddEvidenceORCarImageNotes.this.getString(R.string.TokenId),SharedVariables.userName,SharedVariables.password);       
                        clsNotes notesObj=new clsNotes(0, caseId, 0, addnotesText.getText().toString(),SharedVariables.date());       
                        clsAddNotesRequest clsaddnoteReq=new clsAddNotesRequest(crediantials,notesObj);       
                        wsAddNotes wsAddnote=new wsAddNotes();       
                        int noteId=wsAddnote.addNotes(clsaddnoteReq);
                        if(noteId>0)
                        {
                            notesObj.writeNotesToDBWithId(noteId);
                        }           
                        responceHandler.sendEmptyMessage(0);
            }
            });backgroundthread.start();
    }   

private Handler responceHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (progressDialog != null) {
                if (progressDialog.isShowing()) {
                    Intent in = new Intent();
                    setResult(3,in);//Here I am Setting the Requestcode 1, you can put according to your requirement
                    finish();
                    progressDialog.dismiss();
                }
            }
            if (msg.what == 0) {
                AddEvidenceORCarImageNotes.this.finish();
                /*Intent in = new Intent();
                setResult(3,in);//Here I am Setting the Requestcode 1, you can put according to your requirement
                finish();*/
            }
        }
    };

Comments

  1. here if u use Tablets,then u get Error at line
    progressDialog = ProgressDialog.show(
    AddEvidenceORCarImageNotes.this, "",
    "Uploading Vehicle image...", true);

    so replace above lines with belowcode as follows:
    progressDialog = ProgressDialog.show(
    getActivity(), "",
    "Updatin data...", true);

    ReplyDelete
  2. ////One more important thing u need to remind,We cannot handle(update) UserInterface Views in public void run(){}
    method..so that code should be written in responseHandler of Thread...

    ReplyDelete

Post a Comment