Example usage for android.content Intent setType

List of usage examples for android.content Intent setType

Introduction

In this page you can find the example usage for android.content Intent setType.

Prototype

public @NonNull Intent setType(@Nullable String type) 

Source Link

Document

Set an explicit MIME data type.

Usage

From source file:com.cbtec.eliademy.EliademyLms.java

/**
 * Executes the request.//from   w ww .j  av a 2  s.com
 * 
 * This method is called from the WebView thread. To do a non-trivial amount
 * of work, use: cordova.getThreadPool().execute(runnable);
 * 
 * To run on the UI thread, use:
 * cordova.getActivity().runOnUiThread(runnable);
 * 
 * @param action
 *            The action to execute.
 * @param rawArgs
 *            The exec() arguments in JSON form.
 * @param callbackContext
 *            The callback context used when calling back into JavaScript.
 * @return Whether the action was valid.
 * @throws JSONException
 */
@Override
public boolean execute(String action, JSONArray data, final CallbackContext callbackContext)
        throws JSONException {

    Log.i("HLMS", action);

    if ((action.compareTo("openfilesrv") == 0)) {
        try {
            Uri fileuri = Uri.parse(data.getString(0));
            Intent intent = new Intent(Intent.ACTION_VIEW);
            String mimeextn = android.webkit.MimeTypeMap.getFileExtensionFromUrl(data.getString(0));
            if (mimeextn.isEmpty()) {
                mimeextn = data.getString(0).substring(data.getString(0).indexOf(".") + 1);
                ;
            }
            String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(mimeextn);
            Log.i("HLMS", fileuri + "  " + mimetype);
            intent.setDataAndType(fileuri, mimetype);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            cordova.getActivity().getApplicationContext().startActivity(intent);
            callbackContext.success();
        } catch (Exception e) {
            Log.e("HLMS", "exception", e);
            callbackContext.error(0);
        }
        return true;
    } else if ((action.compareTo("getfilesrv") == 0)) {
        this.mCallbackContext = callbackContext;
        cordova.getThreadPool().execute(new Runnable() {
            @Override
            public void run() {
                try {
                    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                    intent.setType("*/*");// TODO: Restrict file types
                    cordova.startActivityForResult(EliademyLms.this, intent, submitFileCode);
                } catch (Exception e) {
                    Log.e("HLMS", "exception", e);
                    callbackContext.error(0);
                }
                return;
            }
        });
    } else if ((action.compareTo("initservice") == 0)) {
        if (!mIsBound) {
            this.mCallbackContext = callbackContext;
            JSONObject tmp = new JSONObject(data.getString(0));
            String sname = tmp.getString("servicename");
            if (sname.contains("eliademy")) {
                mServiceName = "com.cbtec.serviceeliademy";
            } else {
                // From url determine version 2.2, 2.3, 2.4 and change
                mServiceName = "com.cbtec.service" + sname;
            }
            Log.i("HLMS", "Connecting to service: " + mServiceName);
            doBindService();
        } else {
            callbackContext.success();
        }
        return true;
    } else {
        final String aAction = action;
        final JSONArray aData = data;
        String mappedCmd = null;
        try {
            mappedCmd = mapExecCommand(aData.getString(0));
        } catch (JSONException e) {
            Log.e("HLMS", "exception", e);
        }
        if (mappedCmd == null) {
            Log.i("HLMS", "LMS service call failed " + mappedCmd);
            callbackContext.error(0);// TODO : error enum
            return false;
        }

        final String execCmd = mappedCmd;
        cordova.getThreadPool().execute(new Runnable() {
            @Override
            @SuppressLint("NewApi")
            public void run() {
                Log.i("HLMS", "Runner execute " + aAction + aData.toString());
                if (aAction.compareTo("lmsservice") == 0) {
                    try {
                        String retval = null;
                        Log.i("HLMS", "Execute cmd: " + execCmd);
                        if (execCmd.compareTo("initialize") == 0) {
                            if (mIBinder.initializeService(aData.getString(1))) {
                                String token = mIBinder.eliademyGetWebServiceToken();
                                callbackContext.success(token);
                                return;
                            }
                        } else if (execCmd.compareTo("deinitialize") == 0) {
                            if (mIBinder.deInitializeService(aData.getString(1))) {
                                doUnbindService();
                                callbackContext.success();
                                return;
                            }
                        } else if (execCmd.compareTo("pushregister") == 0) {
                            Log.i("pushdata", aData.getString(1));
                            if (mIBinder.registerPushNotifications(aData.getString(1))) {
                                callbackContext.success();
                                return;
                            }
                        } else if (execCmd.compareTo("pushunregister") == 0) {
                            Log.i("pushdata", aData.getString(1));
                            if (mIBinder.unregisterPushNotifications(aData.getString(1))) {
                                callbackContext.success();
                                return;
                            }
                        } else if (execCmd.compareTo("servicetoken") == 0) {
                            retval = mIBinder.eliademyGetWebServiceToken();
                        } else if (execCmd.compareTo("siteinfo") == 0) {
                            retval = mIBinder.eliademyGetSiteInformation(aData.getString(1));
                        } else if (execCmd.compareTo("get_user_courses") == 0) {
                            retval = mIBinder.eliademyGetUsersCourses(aData.getString(1));
                        } else if (execCmd.compareTo("get_user_forums") == 0) {
                            retval = mIBinder.eliademyGetUserForums(aData.getString(1));
                        } else if (execCmd.compareTo("get_user_info") == 0) {
                            retval = mIBinder.eliademyGetUserInformation(aData.getString(1));
                        } else if (execCmd.compareTo("exec_webservice") == 0) {
                            Log.i("HLMS", "Execute webservice");
                            retval = mIBinder.eliademyExecWebService(aData.getString(0), aData.getString(1));
                        } else if (execCmd.compareTo("course_get_contents") == 0) {
                            retval = mIBinder.eliademyGetCourseContents(aData.getString(1));
                        } else if (execCmd.compareTo("course_get_enrolled_users") == 0) {
                            retval = mIBinder.eliademyGetEnrolledUsers(aData.getString(1));
                        } else {
                            Log.i("HLMS", "LMS service failed " + execCmd);
                            callbackContext.error(0);// TODO : error enum
                        }
                        if (!retval.isEmpty()) {
                            Log.i("HLMS", "LMS service call success");
                            callbackContext.success(retval);
                        } else {
                            Log.i("HLMS", "LMS service call failed");
                            callbackContext.error(0);// TODO : error enum
                        }
                    } catch (Exception e) {
                        Log.e("HLMS", "exception", e);
                        callbackContext.error(e.getMessage());
                        return;
                    }
                } else {
                    Log.i("LMS", "Unsupported action call !!");
                    callbackContext.error(0);
                    return;
                }
            }
        });
    }
    return true;
}

From source file:com.dwdesign.tweetings.fragment.UserProfileFragment.java

private void pickImage() {
    final Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    startActivityForResult(intent, REQUEST_PICK_IMAGE);
}

From source file:com.dwdesign.tweetings.fragment.UserProfileFragment.java

private void pickBannerImage() {
    final Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    startActivityForResult(intent, REQUEST_BANNER_PICK_IMAGE);
}

From source file:jp.ne.sakura.kkkon.android.exceptionhandler.testapp.ExceptionHandlerReportApp.java

/** Called when the activity is first created. */
@Override//w  ww  .j  av  a  2 s.co m
public void onCreate(Bundle savedInstanceState) {
    final Context context = this.getApplicationContext();

    {
        ExceptionHandler.initialize(context);
        if (ExceptionHandler.needReport()) {
            final String fileName = ExceptionHandler.getBugReportFileAbsolutePath();
            final File file = new File(fileName);
            final File fileZip;
            {
                String strFileZip = file.getAbsolutePath();
                {
                    int index = strFileZip.lastIndexOf('.');
                    if (0 < index) {
                        strFileZip = strFileZip.substring(0, index);
                        strFileZip += ".zip";
                    }
                }
                Log.d(TAG, strFileZip);
                fileZip = new File(strFileZip);
                if (fileZip.exists()) {
                    fileZip.delete();
                }
            }
            if (file.exists()) {
                Log.d(TAG, file.getAbsolutePath());
                InputStream inStream = null;
                ZipOutputStream outStream = null;
                try {
                    inStream = new FileInputStream(file);
                    String strFileName = file.getAbsolutePath();
                    {
                        int index = strFileName.lastIndexOf(File.separatorChar);
                        if (0 < index) {
                            strFileName = strFileName.substring(index + 1);
                        }
                    }
                    Log.d(TAG, strFileName);

                    outStream = new ZipOutputStream(new FileOutputStream(fileZip));
                    byte[] buff = new byte[8124];
                    {
                        ZipEntry entry = new ZipEntry(strFileName);
                        outStream.putNextEntry(entry);

                        int len = 0;
                        while (0 < (len = inStream.read(buff))) {
                            outStream.write(buff, 0, len);
                        }
                        outStream.closeEntry();
                    }
                    outStream.finish();
                    outStream.flush();

                } catch (IOException e) {
                    Log.e(TAG, "got exception", e);
                } finally {
                    if (null != outStream) {
                        try {
                            outStream.close();
                        } catch (Exception e) {
                        }
                    }
                    outStream = null;

                    if (null != inStream) {
                        try {
                            inStream.close();
                        } catch (Exception e) {
                        }
                    }
                    inStream = null;
                }
                Log.i(TAG, "zip created");
            }

            if (file.exists()) {
                // upload or send e-mail
                InputStream inStream = null;
                StringBuilder sb = new StringBuilder();
                try {
                    inStream = new FileInputStream(file);
                    byte[] buff = new byte[8124];
                    int readed = 0;
                    do {
                        readed = inStream.read(buff);
                        for (int i = 0; i < readed; i++) {
                            sb.append((char) buff[i]);
                        }
                    } while (readed >= 0);

                    final String str = sb.toString();
                    Log.i(TAG, str);
                } catch (IOException e) {
                    Log.e(TAG, "got exception", e);
                } finally {
                    if (null != inStream) {
                        try {
                            inStream.close();
                        } catch (Exception e) {
                        }
                    }
                    inStream = null;
                }

                AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                final Locale defaultLocale = Locale.getDefault();

                String title = "";
                String message = "";
                String positive = "";
                String negative = "";

                boolean needDefaultLang = true;
                if (null != defaultLocale) {
                    if (defaultLocale.equals(Locale.JAPANESE) || defaultLocale.equals(Locale.JAPAN)) {
                        title = "";
                        message = "?????????";
                        positive = "?";
                        negative = "";
                        needDefaultLang = false;
                    }
                }
                if (needDefaultLang) {
                    title = "ERROR";
                    message = "Got unexpected error. Do you want to send information of error.";
                    positive = "Send";
                    negative = "Cancel";
                }
                alertDialog.setTitle(title);
                alertDialog.setMessage(message);
                alertDialog.setPositiveButton(positive + " mail", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface di, int i) {
                        DefaultUploaderMailClient.upload(context, file,
                                new String[] { "diverKon+sakura@gmail.com" });
                    }
                });
                alertDialog.setNeutralButton(positive + " http", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface di, int i) {
                        DefaultUploaderWeb.upload(ExceptionHandlerReportApp.this, fileZip,
                                "http://kkkon.sakura.ne.jp/android/bug");
                    }
                });
                alertDialog.setNegativeButton(negative, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface di, int i) {
                        ExceptionHandler.clearReport();
                    }
                });
                alertDialog.show();
            }
            // TODO separate activity for crash report
            //DefaultCheckerAPK.checkAPK( this, null );
        }
        ExceptionHandler.registHandler();
    }

    super.onCreate(savedInstanceState);

    /* Create a TextView and set its content.
     * the text is retrieved by calling a native
     * function.
     */
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);

    TextView tv = new TextView(this);
    tv.setText("ExceptionHandler");
    layout.addView(tv);

    Button btn1 = new Button(this);
    btn1.setText("invoke Exception");
    btn1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final int count = 2;
            int[] array = new int[count];
            int value = array[count]; // invoke IndexOutOfBOundsException
        }
    });
    layout.addView(btn1);

    Button btn2 = new Button(this);
    btn2.setText("reinstall apk");
    btn2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            boolean foundApk = false;
            {
                final String apkPath = context.getPackageCodePath(); // API8
                Log.d(TAG, "PackageCodePath: " + apkPath);
                final File fileApk = new File(apkPath);
                if (fileApk.exists()) {
                    foundApk = true;

                    Intent promptInstall = new Intent(Intent.ACTION_VIEW);
                    promptInstall.setDataAndType(Uri.fromFile(fileApk),
                            "application/vnd.android.package-archive");
                    promptInstall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(promptInstall);
                }
            }

            if (false == foundApk) {
                for (int i = 0; i < 10; ++i) {
                    File fileApk = new File("/data/app/" + context.getPackageName() + "-" + i + ".apk");
                    Log.d(TAG, "check apk:" + fileApk.getAbsolutePath());
                    if (fileApk.exists()) {
                        Log.i(TAG, "apk found. path=" + fileApk.getAbsolutePath());
                        /*
                         * // require parmission
                        {
                        final String strCmd = "pm install -r " + fileApk.getAbsolutePath();
                        try
                        {
                            Runtime.getRuntime().exec( strCmd );
                        }
                        catch ( IOException e )
                        {
                            Log.e( TAG, "got exception", e );
                        }
                        }
                        */
                        Intent promptInstall = new Intent(Intent.ACTION_VIEW);
                        promptInstall.setDataAndType(Uri.fromFile(fileApk),
                                "application/vnd.android.package-archive");
                        promptInstall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        context.startActivity(promptInstall);
                        break;
                    }
                }
            }
        }
    });
    layout.addView(btn2);

    Button btn3 = new Button(this);
    btn3.setText("check apk");
    btn3.setOnClickListener(new View.OnClickListener() {
        private boolean checkApk(final File fileApk, final ZipEntryFilter filter) {
            final boolean[] result = new boolean[1];
            result[0] = true;

            final Thread thread = new Thread(new Runnable() {

                @Override
                public void run() {
                    if (fileApk.exists()) {
                        ZipFile zipFile = null;
                        try {
                            zipFile = new ZipFile(fileApk);
                            List<ZipEntry> list = new ArrayList<ZipEntry>(zipFile.size());
                            for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements();) {
                                ZipEntry ent = e.nextElement();
                                Log.d(TAG, ent.getName());
                                Log.d(TAG, "" + ent.getSize());
                                final boolean accept = filter.accept(ent);
                                if (accept) {
                                    list.add(ent);
                                }
                            }

                            Log.d(TAG, Build.CPU_ABI); // API 4
                            Log.d(TAG, Build.CPU_ABI2); // API 8

                            final String[] abiArray = { Build.CPU_ABI // API 4
                                    , Build.CPU_ABI2 // API 8
                            };

                            String abiMatched = null;
                            {
                                boolean foundMatched = false;
                                for (final String abi : abiArray) {
                                    if (null == abi) {
                                        continue;
                                    }
                                    if (0 == abi.length()) {
                                        continue;
                                    }

                                    for (final ZipEntry entry : list) {
                                        Log.d(TAG, entry.getName());

                                        final String prefixABI = "lib/" + abi + "/";
                                        if (entry.getName().startsWith(prefixABI)) {
                                            abiMatched = abi;
                                            foundMatched = true;
                                            break;
                                        }
                                    }

                                    if (foundMatched) {
                                        break;
                                    }
                                }
                            }
                            Log.d(TAG, "matchedAbi=" + abiMatched);

                            if (null != abiMatched) {
                                boolean needReInstall = false;

                                for (final ZipEntry entry : list) {
                                    Log.d(TAG, entry.getName());

                                    final String prefixABI = "lib/" + abiMatched + "/";
                                    if (entry.getName().startsWith(prefixABI)) {
                                        final String jniName = entry.getName().substring(prefixABI.length());
                                        Log.d(TAG, "jni=" + jniName);

                                        final String strFileDst = context.getApplicationInfo().nativeLibraryDir
                                                + "/" + jniName;
                                        Log.d(TAG, strFileDst);
                                        final File fileDst = new File(strFileDst);
                                        if (!fileDst.exists()) {
                                            Log.w(TAG, "needReInstall: content missing " + strFileDst);
                                            needReInstall = true;
                                        } else {
                                            assert (entry.getSize() <= Integer.MAX_VALUE);
                                            if (fileDst.length() != entry.getSize()) {
                                                Log.w(TAG, "needReInstall: size broken " + strFileDst);
                                                needReInstall = true;
                                            } else {
                                                //org.apache.commons.io.IOUtils.contentEquals( zipFile.getInputStream( entry ), new FileInputStream(fileDst) );

                                                final int size = (int) entry.getSize();
                                                byte[] buffSrc = new byte[size];

                                                {
                                                    InputStream inStream = null;
                                                    try {
                                                        inStream = zipFile.getInputStream(entry);
                                                        int pos = 0;
                                                        {
                                                            while (pos < size) {
                                                                final int ret = inStream.read(buffSrc, pos,
                                                                        size - pos);
                                                                if (ret <= 0) {
                                                                    break;
                                                                }
                                                                pos += ret;
                                                            }
                                                        }
                                                    } catch (IOException e) {
                                                        Log.d(TAG, "got exception", e);
                                                    } finally {
                                                        if (null != inStream) {
                                                            try {
                                                                inStream.close();
                                                            } catch (Exception e) {
                                                            }
                                                        }
                                                    }
                                                }
                                                byte[] buffDst = new byte[(int) fileDst.length()];
                                                {
                                                    InputStream inStream = null;
                                                    try {
                                                        inStream = new FileInputStream(fileDst);
                                                        int pos = 0;
                                                        {
                                                            while (pos < size) {
                                                                final int ret = inStream.read(buffDst, pos,
                                                                        size - pos);
                                                                if (ret <= 0) {
                                                                    break;
                                                                }
                                                                pos += ret;
                                                            }
                                                        }
                                                    } catch (IOException e) {
                                                        Log.d(TAG, "got exception", e);
                                                    } finally {
                                                        if (null != inStream) {
                                                            try {
                                                                inStream.close();
                                                            } catch (Exception e) {
                                                            }
                                                        }
                                                    }
                                                }

                                                if (Arrays.equals(buffSrc, buffDst)) {
                                                    Log.d(TAG, " content equal " + strFileDst);
                                                    // OK
                                                } else {
                                                    Log.w(TAG, "needReInstall: content broken " + strFileDst);
                                                    needReInstall = true;
                                                }
                                            }

                                        }

                                    }
                                } // for ZipEntry

                                if (needReInstall) {
                                    // need call INSTALL APK
                                    Log.w(TAG, "needReInstall apk");
                                    result[0] = false;
                                } else {
                                    Log.d(TAG, "no need ReInstall apk");
                                }
                            }

                        } catch (IOException e) {
                            Log.d(TAG, "got exception", e);
                        } finally {
                            if (null != zipFile) {
                                try {
                                    zipFile.close();
                                } catch (Exception e) {
                                }
                            }
                        }
                    }
                }

            });
            thread.setName("check jni so");

            thread.start();
            /*
            while ( thread.isAlive() )
            {
            Log.d( TAG, "check thread.id=" + android.os.Process.myTid() + ",state=" + thread.getState() );
            if ( ! thread.isAlive() )
            {
                break;
            }
            AlertDialog.Builder alertDialog = new AlertDialog.Builder( ExceptionHandlerTestApp.this );
            final Locale defaultLocale = Locale.getDefault();
                    
            String title = "";
            String message = "";
            String positive = "";
            String negative = "";
                    
            boolean needDefaultLang = true;
            if ( null != defaultLocale )
            {
                if ( defaultLocale.equals( Locale.JAPANESE ) || defaultLocale.equals( Locale.JAPAN ) )
                {
                    title = "";
                    message = "???????";
                    positive = "?";
                    negative = "";
                    needDefaultLang = false;
                }
            }
            if ( needDefaultLang )
            {
                title = "INFO";
                message = "Now checking installation. Cancel check?";
                positive = "Wait";
                negative = "Cancel";
            }
            alertDialog.setTitle( title );
            alertDialog.setMessage( message );
            alertDialog.setPositiveButton( positive, null);
            alertDialog.setNegativeButton( negative, new DialogInterface.OnClickListener() {
                    
                @Override
                public void onClick(DialogInterface di, int i) {
                    if ( thread.isAlive() )
                    {
                        Log.d( TAG, "request interrupt" );
                        thread.interrupt();
                    }
                    else
                    {
                        // nothing
                    }
                }
            } );
                    
            if ( ! thread.isAlive() )
            {
                break;
            }
                    
            alertDialog.show();
                    
            if ( ! Thread.State.RUNNABLE.equals(thread.getState()) )
            {
                break;
            }
                    
            }
            */

            try {
                thread.join();
            } catch (InterruptedException e) {
                Log.d(TAG, "got exception", e);
            }

            return result[0];
        }

        @Override
        public void onClick(View view) {
            boolean foundApk = false;
            {
                final String apkPath = context.getPackageCodePath(); // API8
                Log.d(TAG, "PackageCodePath: " + apkPath);
                final File fileApk = new File(apkPath);
                this.checkApk(fileApk, new ZipEntryFilter() {
                    @Override
                    public boolean accept(ZipEntry entry) {
                        if (entry.isDirectory()) {
                            return false;
                        }

                        final String filename = entry.getName();
                        if (filename.startsWith("lib/")) {
                            return true;
                        }

                        return false;
                    }
                });
            }

        }
    });
    layout.addView(btn3);

    Button btn4 = new Button(this);
    btn4.setText("print dir and path");
    btn4.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            {
                final File file = context.getCacheDir();
                Log.d(TAG, "Ctx.CacheDir=" + file.getAbsoluteFile());
            }
            {
                final File file = context.getExternalCacheDir(); // API 8
                if (null == file) {
                    // no permission
                    Log.d(TAG, "Ctx.ExternalCacheDir=");
                } else {
                    Log.d(TAG, "Ctx.ExternalCacheDir=" + file.getAbsolutePath());
                }
            }
            {
                final File file = context.getFilesDir();
                Log.d(TAG, "Ctx.FilesDir=" + file.getAbsolutePath());
            }
            {
                final String value = context.getPackageResourcePath();
                Log.d(TAG, "Ctx.PackageResourcePath=" + value);
            }
            {
                final String[] files = context.fileList();
                if (null == files) {
                    Log.d(TAG, "Ctx.fileList=" + files);
                } else {
                    for (final String filename : files) {
                        Log.d(TAG, "Ctx.fileList=" + filename);
                    }
                }
            }

            {
                final File file = Environment.getDataDirectory();
                Log.d(TAG, "Env.DataDirectory=" + file.getAbsolutePath());
            }
            {
                final File file = Environment.getDownloadCacheDirectory();
                Log.d(TAG, "Env.DownloadCacheDirectory=" + file.getAbsolutePath());
            }
            {
                final File file = Environment.getExternalStorageDirectory();
                Log.d(TAG, "Env.ExternalStorageDirectory=" + file.getAbsolutePath());
            }
            {
                final File file = Environment.getRootDirectory();
                Log.d(TAG, "Env.RootDirectory=" + file.getAbsolutePath());
            }
            {
                final ApplicationInfo appInfo = context.getApplicationInfo();
                Log.d(TAG, "AppInfo.dataDir=" + appInfo.dataDir);
                Log.d(TAG, "AppInfo.nativeLibraryDir=" + appInfo.nativeLibraryDir); // API 9
                Log.d(TAG, "AppInfo.publicSourceDir=" + appInfo.publicSourceDir);
                {
                    final String[] sharedLibraryFiles = appInfo.sharedLibraryFiles;
                    if (null == sharedLibraryFiles) {
                        Log.d(TAG, "AppInfo.sharedLibraryFiles=" + sharedLibraryFiles);
                    } else {
                        for (final String fileName : sharedLibraryFiles) {
                            Log.d(TAG, "AppInfo.sharedLibraryFiles=" + fileName);
                        }
                    }
                }
                Log.d(TAG, "AppInfo.sourceDir=" + appInfo.sourceDir);
            }
            {
                Log.d(TAG, "System.Properties start");
                final Properties properties = System.getProperties();
                if (null != properties) {
                    for (final Object key : properties.keySet()) {
                        String value = properties.getProperty((String) key);
                        Log.d(TAG, " key=" + key + ",value=" + value);
                    }
                }
                Log.d(TAG, "System.Properties end");
            }
            {
                Log.d(TAG, "System.getenv start");
                final Map<String, String> mapEnv = System.getenv();
                if (null != mapEnv) {
                    for (final Map.Entry<String, String> entry : mapEnv.entrySet()) {
                        final String key = entry.getKey();
                        final String value = entry.getValue();
                        Log.d(TAG, " key=" + key + ",value=" + value);
                    }
                }
                Log.d(TAG, "System.getenv end");
            }
        }
    });
    layout.addView(btn4);

    Button btn5 = new Button(this);
    btn5.setText("check INSTALL_NON_MARKET_APPS");
    btn5.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            SettingsCompat.initialize(context);
            if (SettingsCompat.isAllowedNonMarketApps()) {
                Log.d(TAG, "isAllowdNonMarketApps=true");
            } else {
                Log.d(TAG, "isAllowdNonMarketApps=false");
            }
        }
    });
    layout.addView(btn5);

    Button btn6 = new Button(this);
    btn6.setText("send email");
    btn6.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent mailto = new Intent();
            mailto.setAction(Intent.ACTION_SENDTO);
            mailto.setType("message/rfc822");
            mailto.setData(Uri.parse("mailto:"));
            mailto.putExtra(Intent.EXTRA_EMAIL, new String[] { "" });
            mailto.putExtra(Intent.EXTRA_SUBJECT, "[BugReport] " + context.getPackageName());
            mailto.putExtra(Intent.EXTRA_TEXT, "body text");
            //mailto.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
            //context.startActivity( mailto );
            Intent intent = Intent.createChooser(mailto, "Send Email");
            if (null != intent) {
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                try {
                    context.startActivity(intent);
                } catch (android.content.ActivityNotFoundException e) {
                    Log.d(TAG, "got Exception", e);
                }
            }
        }
    });
    layout.addView(btn6);

    Button btn7 = new Button(this);
    btn7.setText("upload http thread");
    btn7.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Log.d(TAG, "brd=" + Build.BRAND);
            Log.d(TAG, "prd=" + Build.PRODUCT);

            //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS)
            Log.d(TAG, "fng=" + Build.FINGERPRINT);
            final List<NameValuePair> list = new ArrayList<NameValuePair>(16);
            list.add(new BasicNameValuePair("fng", Build.FINGERPRINT));

            final Thread thread = new Thread(new Runnable() {

                @Override
                public void run() {
                    Log.d(TAG, "upload thread tid=" + android.os.Process.myTid());
                    try {
                        HttpPost httpPost = new HttpPost("http://kkkon.sakura.ne.jp/android/bug");
                        //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) );
                        httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8));
                        DefaultHttpClient httpClient = new DefaultHttpClient();
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,
                                new Integer(5 * 1000));
                        httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
                                new Integer(5 * 1000));
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        // <uses-permission android:name="android.permission.INTERNET"/>
                        // got android.os.NetworkOnMainThreadException, run at UI Main Thread
                        HttpResponse response = httpClient.execute(httpPost);
                        Log.d(TAG, "response=" + response.getStatusLine().getStatusCode());
                    } catch (Exception e) {
                        Log.d(TAG, "got Exception. msg=" + e.getMessage(), e);
                    }
                    Log.d(TAG, "upload finish");
                }
            });
            thread.setName("upload crash");

            thread.start();
            /*
            while ( thread.isAlive() )
            {
            Log.d( TAG, "thread tid=" + android.os.Process.myTid() + ",state=" + thread.getState() );
            if ( ! thread.isAlive() )
            {
                break;
            }
            AlertDialog.Builder alertDialog = new AlertDialog.Builder( ExceptionHandlerTestApp.this );
            final Locale defaultLocale = Locale.getDefault();
                    
            String title = "";
            String message = "";
            String positive = "";
            String negative = "";
                    
            boolean needDefaultLang = true;
            if ( null != defaultLocale )
            {
                if ( defaultLocale.equals( Locale.JAPANESE ) || defaultLocale.equals( Locale.JAPAN ) )
                {
                    title = "";
                    message = "???????";
                    positive = "?";
                    negative = "";
                    needDefaultLang = false;
                }
            }
            if ( needDefaultLang )
            {
                title = "INFO";
                message = "Now uploading error information. Cancel upload?";
                positive = "Wait";
                negative = "Cancel";
            }
            alertDialog.setTitle( title );
            alertDialog.setMessage( message );
            alertDialog.setPositiveButton( positive, null);
            alertDialog.setNegativeButton( negative, new DialogInterface.OnClickListener() {
                    
                @Override
                public void onClick(DialogInterface di, int i) {
                    if ( thread.isAlive() )
                    {
                        Log.d( TAG, "request interrupt" );
                        thread.interrupt();
                    }
                    else
                    {
                        // nothing
                    }
                }
            } );
                    
            if ( ! thread.isAlive() )
            {
                break;
            }
                    
            alertDialog.show();
                    
            if ( ! Thread.State.RUNNABLE.equals(thread.getState()) )
            {
                break;
            }
                    
            }
            */

            /*
            try
            {
            thread.join(); // must call. leak handle...
            }
            catch ( InterruptedException e )
            {
            Log.d( TAG, "got Exception", e );
            }
            */
        }
    });
    layout.addView(btn7);

    Button btn8 = new Button(this);
    btn8.setText("upload http AsyncTask");
    btn8.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            AsyncTask<String, Void, Boolean> asyncTask = new AsyncTask<String, Void, Boolean>() {

                @Override
                protected Boolean doInBackground(String... paramss) {
                    Boolean result = true;
                    Log.d(TAG, "upload AsyncTask tid=" + android.os.Process.myTid());
                    try {
                        //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS)
                        Log.d(TAG, "fng=" + Build.FINGERPRINT);
                        final List<NameValuePair> list = new ArrayList<NameValuePair>(16);
                        list.add(new BasicNameValuePair("fng", Build.FINGERPRINT));

                        HttpPost httpPost = new HttpPost(paramss[0]);
                        //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) );
                        httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8));
                        DefaultHttpClient httpClient = new DefaultHttpClient();
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,
                                new Integer(5 * 1000));
                        httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
                                new Integer(5 * 1000));
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        // <uses-permission android:name="android.permission.INTERNET"/>
                        // got android.os.NetworkOnMainThreadException, run at UI Main Thread
                        HttpResponse response = httpClient.execute(httpPost);
                        Log.d(TAG, "response=" + response.getStatusLine().getStatusCode());
                    } catch (Exception e) {
                        Log.d(TAG, "got Exception. msg=" + e.getMessage(), e);
                        result = false;
                    }
                    Log.d(TAG, "upload finish");
                    return result;
                }

            };

            asyncTask.execute("http://kkkon.sakura.ne.jp/android/bug");
            asyncTask.isCancelled();
        }
    });
    layout.addView(btn8);

    Button btn9 = new Button(this);
    btn9.setText("call checkAPK");
    btn9.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final boolean result = DefaultCheckerAPK.checkAPK(ExceptionHandlerReportApp.this, null);
            Log.i(TAG, "checkAPK result=" + result);
        }
    });
    layout.addView(btn9);

    setContentView(layout);
}

From source file:com.VVTeam.ManHood.Fragment.HistogramFragment.java

private void initViews(View view) {
    parentLayout = (RelativeLayout) view.findViewById(R.id.fragment_histogram_parent_relative_layout);
    /*BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = 2;/*w  w w . j av  a  2s .  co  m*/
    parentLayout.setBackgroundDrawable(new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.histogram_bg, options)));*/
    settingsRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_settings_relative_layout);
    markRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_mark_relative_layout);
    worldRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_world_relative);
    //        worldRelative.setSelected(true);
    worldRelative.setBackgroundResource(R.drawable.cell_p);
    areaRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_area_relative);
    hoodRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_hood_relative);
    yourResultButton = (Button) view.findViewById(R.id.fragment_histogram_your_result_button);

    contentRelative = (RelativeLayout) view.findViewById(R.id.fragment_histogram_content_relative);

    RelativeLayout shareRelative = (RelativeLayout) view
            .findViewById(R.id.fragment_histogram_share_button_relative);
    shareRelative.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            GoogleTracker.StarSendEvent(getActivity(), "ui_action", "user_action", "histogram_share");

            Bitmap image = makeSnapshot();

            File pictureFile = getOutputMediaFile();
            try {
                FileOutputStream fos = new FileOutputStream(pictureFile);
                image.compress(Bitmap.CompressFormat.PNG, 90, fos);
                fos.close();

            } catch (Exception e) {

            }

            //            String pathofBmp = Images.Media.insertImage(getActivity().getContentResolver(), makeSnapshot(), "Man Hood App", null);
            //             Uri bmpUri = Uri.parse(pathofBmp);
            Uri bmpUri = Uri.fromFile(pictureFile);
            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            emailIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
            emailIntent.setType("image/png");
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Man Hood App");
            getActivity().startActivity(emailIntent);

        }
    });

    polarPlot = (PolarPlot) view.findViewById(R.id.polarPlot);

    thicknessHisto = (Histogram) view.findViewById(R.id.thicknessHisto);
    thicknessHisto.setOrientation(ORIENT.LEFT);
    thicknessHisto.setBackgroundColor(Color.TRANSPARENT);
    lengthHisto = (Histogram) view.findViewById(R.id.lengthHistogram);
    lengthHisto.setOrientation(ORIENT.RIGHT);
    lengthHisto.setBackgroundColor(Color.TRANSPARENT);
    girthHisto = (Histogram) view.findViewById(R.id.girthHistogram);
    girthHisto.setOrientation(ORIENT.BOTTOM);
    girthHisto.setBackgroundColor(Color.TRANSPARENT);

    lengthHisto.setCallBackListener(new HistogramCallBack() {

        @Override
        public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState,
                float value, HistogramBin bin) {
            // TODO Auto-generated method stub
            if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) {
                histogramSelected = true;

                setNearestUserID(usersData.userIDWithNearestLength(value));

                setSelection(true, girthHisto, usersData.girthOfUserWithID(nearestUserID));
                setSelection(true, thicknessHisto, usersData.thicknessOfUserWithID(nearestUserID));
                //               setSelection(false, lengthHisto, 0.0f);
                setSelection(true, lengthHisto, value);

                setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData);
            } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) {
                histogramSelected = false;

                setNearestUserID(null);
                setSelectionForAverage();
                setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData);
            } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) {

            }

        }
    });

    girthHisto.setCallBackListener(new HistogramCallBack() {

        @Override
        public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState,
                float value, HistogramBin bin) {
            // TODO Auto-generated method stub
            if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) {
                histogramSelected = true;

                setNearestUserID(usersData.userIDWithNearestGirth(value));

                setSelection(true, lengthHisto, usersData.lengthOfUserWithID(nearestUserID));
                setSelection(true, thicknessHisto, usersData.thicknessOfUserWithID(nearestUserID));
                //               setSelection(false, girthHisto, 0.0f);
                setSelection(true, girthHisto, value);

                setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData);
            } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) {
                histogramSelected = false;

                setNearestUserID(null);

                setSelectionForAverage();
                setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData);
            } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) {

            }

        }
    });

    thicknessHisto.setCallBackListener(new HistogramCallBack() {

        @Override
        public void setValueSelectionChangedBlock(Histogram histo, HistogramSelectionState selectionState,
                float value, HistogramBin bin) {
            // TODO Auto-generated method stub
            if (selectionState == HistogramSelectionState.HistogramSelectionStateSelected) {
                histogramSelected = true;

                setNearestUserID(usersData.userIDWithNearestThickness(value));

                setSelection(true, girthHisto, usersData.girthOfUserWithID(nearestUserID));
                setSelection(true, lengthHisto, usersData.lengthOfUserWithID(nearestUserID));
                //                 setSelection(false, thicknessHisto, 0.0f);
                setSelection(true, thicknessHisto, value);

                setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData);
            } else if (selectionState == HistogramSelectionState.HistogramSelectionStateNotSelected) {
                histogramSelected = false;

                setNearestUserID(null);
                setSelectionForAverage();
                setupPolarPlotWithCurrentUserID(nearestUserID, usersData, selfUserData);
            } else if (selectionState == HistogramSelectionState.HistogramSelectionStateDelayedFinish) {

            }

        }
    });

    textBoxTitleLabel = (TextView) view.findViewById(R.id.txtBoxTitle);
    textBoxTitleLabel.setText("AVERAGE");

    layoutSubTitle = (LinearLayout) view.findViewById(R.id.layoutSubTitle);
    layoutSubTitle.setVisibility(View.INVISIBLE);
    textBoxSubtitleLabel = (TextView) view.findViewById(R.id.txtBoxSubTitleLabel);
    textBoxSubtitleValueLabel = (TextView) view.findViewById(R.id.txtBoxSubTitleValue);

    lengthSelectedLabel = (TextView) view.findViewById(R.id.txtlengthselected);
    lengthSelectedLabel.setText("50%");
    lengthTOPLabel = (TextView) view.findViewById(R.id.lengthTOPLabel);

    girthSelectedLabel = (TextView) view.findViewById(R.id.txtgirthselected);
    girthSelectedLabel.setText("50%");
    girthTOPLabel = (TextView) view.findViewById(R.id.girthTOPLabel);

    thicknessSelectedLabel = (TextView) view.findViewById(R.id.txtthicknessselected);
    thicknessSelectedLabel.setText("50%");
    thinkestAtTOPLabel = (TextView) view.findViewById(R.id.thinkestAtTOPLabel);

    curvedSelectedLabel = (TextView) view.findViewById(R.id.txtcurvedselected);
    curvedSelectedLabel.setText("0");

    girthTopLB = (TextView) view.findViewById(R.id.girthTop);
    girthMiddleLB = (TextView) view.findViewById(R.id.girthMiddle);
    girthBottomLB = (TextView) view.findViewById(R.id.girthBottom);

    thicknessTopLB = (TextView) view.findViewById(R.id.thicknessTop);
    thicknessMiddleLB = (TextView) view.findViewById(R.id.thicknessMiddle);
    thicknessBottomLB = (TextView) view.findViewById(R.id.thicknessBottom);

    lengthTopLB = (TextView) view.findViewById(R.id.lengthTop);
    lengthMiddleLB = (TextView) view.findViewById(R.id.lengthMiddle);
    lengthBottomLB = (TextView) view.findViewById(R.id.lengthBottom);

    settingsRelative.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((MainActivity) getActivity()).openSettingsActivity();
        }
    });
    markRelative.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((MainActivity) getActivity()).openCertificateActivity();
        }
    });

    worldRelative.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setSelectedRange(SliceRange.SliceRangeAll);
            updateRangeSwitch();
        }
    });
    areaRelative.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setSelectedRange(SliceRange.SliceRange200);
            updateRangeSwitch();
        }
    });
    hoodRelative.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setSelectedRange(SliceRange.SliceRange20);
            updateRangeSwitch();
        }
    });

    yourResultButton.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub

            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                youTouchDown();
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
                youTouchUp();
                //               final Handler handler = new Handler();
                //                handler.postDelayed(new Runnable() {
                //                    @Override
                //                    public void run() {
                //                       youTouchUp();             
                //                    }
                //                }, 2000);
            }

            return true;
        }
    });

    RequestManager.getInstance().checkUser();

    /* in-app billing */
    String base64EncodedPublicKey = LICENSE_KEY;

    // Create the helper, passing it our context and the public key to verify signatures with
    Log.d(TAG, "Creating IAB helper.");
    mHelper = new IabHelper(getActivity(), base64EncodedPublicKey);

    // enable debug logging (for a production application, you should set this to false).
    mHelper.enableDebugLogging(true);

    // Start setup. This is asynchronous and the specified listener
    // will be called once setup completes.
    Log.d(TAG, "Starting setup.");
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        public void onIabSetupFinished(IabResult result) {
            Log.d(TAG, "Setup finished.");

            if (!result.isSuccess()) {
                // Oh noes, there was a problem.
                Log.d(TAG, "Problem setting up in-app billing: " + result);
                return;
            }

            // Have we been disposed of in the meantime? If so, quit.
            if (mHelper == null)
                return;

            // IAB is fully set up. Now, let's get an inventory of stuff we own.
            Log.d(TAG, "Setup successful. Querying inventory.");
            mHelper.queryInventoryAsync(mGotInventoryListener);
        }
    });

}

From source file:com.fvd.nimbus.PaintActivity.java

void setCustomBackground(DrawView v) {
    Intent fileChooserIntent = new Intent();
    fileChooserIntent.addCategory(Intent.CATEGORY_OPENABLE);
    fileChooserIntent.setType("image/*");
    fileChooserIntent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(fileChooserIntent, "Select Picture"), 1);
    //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
    overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
}

From source file:com.mibr.android.intelligentreminder.INeedToo.java

public void TrialIsEndingWarningOrLicensingFailed(String verbiage, Boolean wereDealingWithLicensingHere) {
    final Boolean wdwlh = wereDealingWithLicensingHere;
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(verbiage).setCancelable(false)
            .setNeutralButton(R.string.msg_cus, new DialogInterface.OnClickListener() {
                @Override//  w w  w .  j  a  v  a  2  s  .  c om
                public void onClick(DialogInterface dialog, int id) {
                    String[] mailto = { "diamondsoftware222@gmail.com", "" };
                    Intent sendIntent = new Intent(Intent.ACTION_SEND);
                    sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
                    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "".toString());
                    sendIntent.putExtra(Intent.EXTRA_TEXT, "".toString());
                    sendIntent.setType("text/plain");
                    startActivity(Intent.createChooser(sendIntent, "Send EMail..."));
                }
            }).setPositiveButton(R.string.msg_register, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    Intent i4 = new Intent(INeedToo.this, INeedToPay.class);
                    startActivity(i4);
                }
            }).setNegativeButton(R.string.msg_cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (wdwlh) {
                        INeedToo.this.finish();
                    }
                }
            });
    AlertDialog alert = builder.create();
    try {
        alert.show();
    } catch (Exception ee33) {
        int bkhere = 3;
        int bkhere2 = bkhere;
    }
}

From source file:com.fvd.nimbus.PaintActivity.java

public void getPicture() {
    try {/* www .  j av a  2 s.c  om*/
        showProgress(true);
        Intent fileChooserIntent = new Intent();
        fileChooserIntent.addCategory(Intent.CATEGORY_OPENABLE);
        fileChooserIntent.setType("image/*");
        fileChooserIntent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(fileChooserIntent, "Select Picture"), TAKE_PICTURE);
    } catch (Exception e) {
        appSettings.appendLog("main:onClick  " + e.getMessage());
        showProgress(false);
    }
}

From source file:com.speed.traquer.app.TraqComplaintTaxi.java

private void PromptCustomDialog() {

    // Create custom dialog object
    final Dialog dialog = new Dialog(TraqComplaintTaxi.this);
    // Include dialog.xml file
    dialog.setContentView(R.layout.activity_submit_social);
    // Set dialog title
    dialog.setTitle("Submit via");

    // set values for custom dialog components - text, image and button
    final TextView twitterText = (TextView) dialog.findViewById(R.id.textTwitterDialog);
    twitterText.setText("Twitter");

    final TextView facebookText = (TextView) dialog.findViewById(R.id.textFacebookDialog);
    facebookText.setText("Facebook");

    final TextView defaultText = (TextView) dialog.findViewById(R.id.textDefaultDialog);
    defaultText.setText("Default");
    defaultText.setTextColor(getResources().getColor(R.color.Orange));

    final TextView smsText = (TextView) dialog.findViewById(R.id.textSMSDialog);
    smsText.setText("SMS");

    final ImageView image = (ImageView) dialog.findViewById(R.id.imageDialog);
    image.setImageResource(R.drawable.icon_twitter);

    final ImageView imageFb = (ImageView) dialog.findViewById(R.id.imageDialogFb);
    imageFb.setImageResource(R.drawable.ic_fb_grey);

    final ImageView imageDefault = (ImageView) dialog.findViewById(R.id.imageDialogDefault);
    imageDefault.setImageResource(R.drawable.icon_traquer_color);
    isDefaultSelected = true;//from w  w w. j  av  a 2  s . co m

    final ImageView imageSMS = (ImageView) dialog.findViewById(R.id.imageDialogSMS);
    imageSMS.setImageResource(R.drawable.icon_sms);

    dialog.show();

    //Retrieve form info
    taxi_id = inputTaxi.getText().toString().toUpperCase();
    taxi_id = taxi_id.replace(" ", "");
    taxi_comp = actv_comp_taxi.getText().toString();
    taxi_driver = taxiDriver.getText().toString();
    taxi_license = taxiLic.getText().toString();
    loc_frm = actv_from.getText().toString();
    loc_to = actv_to.getText().toString();
    dateBus = editDate.getText().toString();
    timeBus = editTime.getText().toString();
    curr_time = editCurrTime.getText().toString();
    user_name = SaveSharedPreference.getUserName(TraqComplaintTaxi.this);

    //Twitter Button
    final RelativeLayout twitterLogin = (RelativeLayout) dialog.findViewById(R.id.twitterImageButton);
    twitterLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isTwitterSelected) {
                image.setImageResource(R.drawable.icon_twitter);
                twitterText.setTextColor(getResources().getColor(R.color.DarkGray));
                isTwitterSelected = false;
            } else {
                loginToTwitter();
                image.setImageResource(R.drawable.icon_twitter_blue);
                twitterText.setTextColor(getResources().getColor(R.color.TwitterBlue));
                isTwitterSelected = true;
            }

        }
    });

    //facebook Button
    final RelativeLayout facebookLogin = (RelativeLayout) dialog.findViewById(R.id.facebookImageButton);
    facebookLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isFacebookSelected) {
                imageFb.setImageResource(R.drawable.ic_fb_grey);
                if (fbUserName != null)
                    facebookText.setText("Facebook");

                facebookText.setTextColor(getResources().getColor(R.color.DarkGray));
                isFacebookSelected = false;
            } else {

                //loginToTwitter();
                // start Facebook Login
                loginToFacebook();
                if (fbUserName != null)
                    facebookText.setText(fbUserName);
                imageFb.setImageResource(R.drawable.ic_fb_blue);
                facebookText.setTextColor(getResources().getColor(R.color.TwitterBlue));
                isFacebookSelected = true;
            }

        }
    });

    //SMS Button
    final RelativeLayout SMSLogin = (RelativeLayout) dialog.findViewById(R.id.smsImageButton);
    SMSLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isSmsSelected) {
                imageSMS.setImageResource(R.drawable.icon_sms);
                smsText.setTextColor(getResources().getColor(R.color.DarkGray));
                isSmsSelected = false;
            } else {
                imageSMS.setImageResource(R.drawable.icon_sms_color);
                smsText.setTextColor(getResources().getColor(R.color.Orange));
                isSmsSelected = true;
            }

        }
    });

    /*/Default Button
    final RelativeLayout defaultLogin = (RelativeLayout)dialog.findViewById(R.id.defaultImageButton);
    defaultLogin.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if(isDefaultSelected)
        {
            imageDefault.setImageResource(R.drawable.icon_traquer_color);
            defaultText.setTextColor(getResources().getColor(R.color.Orange));
            isDefaultSelected = false;
        }
        else
        {
            imageDefault.setImageResource(R.drawable.icon_traquer_color);
            defaultText.setTextColor(getResources().getColor(R.color.Orange));
            isDefaultSelected = true;
        }
            
    }
    });*/

    //Submit Button
    Button declineButton = (Button) dialog.findViewById(R.id.submitButton);
    // if decline button is clicked, close the custom dialog
    declineButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //submit complaint
            isSubmitButtonClicked = true;
            if (isNetworkConnected() == true) {
                Toast.makeText(TraqComplaintTaxi.this, "Complaint sent. Thank you for taking action!",
                        Toast.LENGTH_SHORT).show();

                //Combine Strings for Twitter Status

                String status = taxi_id + ", " + taxi_comp + " taxi is speeding with " + speedTaxiExceed
                        + "km/h at " + Double.toString(gLatitude) + "N, " + Double.toString(gLongitude)
                        + "E, " + curr_time + " @aduanSPAD @MyTraquer #Traquer";

                finalStatus = status;

                if (isFacebookSelected) {
                    //share to facebook
                    ShareToFacebook(status);
                    //publishFeedDialog();
                }

                if (isTwitterSelected) {

                    //Toast.makeText(TraqComplaintTaxi.this, Long.toString(twitterID) + userName, Toast.LENGTH_SHORT).show();

                    // Check for blank text
                    if (status.trim().length() > 0) {
                        // update status
                        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1) {
                            new updateTwitterStatus().execute(status);
                        }

                        else
                            new updateTwitterStatus().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, status);

                    } else {
                        // EditText is empty
                        Toast.makeText(getApplicationContext(), "Please enter status message",
                                Toast.LENGTH_SHORT).show();
                    }

                } else {
                    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1)
                        new InsertForm().execute();
                    else
                        new InsertForm().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

                }

                // Close dialog
                dialog.dismiss();

            } else {
                if (isSmsSelected) {
                    Log.i("Clicks", "You clicked sent.");

                    Intent sendIntent = new Intent(Intent.ACTION_VIEW);
                    sendIntent.putExtra("address", "15888");
                    sendIntent.putExtra("sms_body",
                            "SPAD Aduan " + taxi_id + ", " + taxi_comp + " taxi is speeding with "
                                    + speedTaxiExceed + "km/h at " + Double.toString(gLatitude) + "N, "
                                    + Double.toString(gLongitude) + "E, " + curr_time + " - Traquer");
                    sendIntent.setType("vnd.android-dir/mms-sms");
                    startActivity(sendIntent);

                    //1800-88-7723
                } else {
                    Toast.makeText(TraqComplaintTaxi.this,
                            "Failed to send. Please check your network connection.", Toast.LENGTH_SHORT).show();
                }
            }

        }

    });
    //TraqComplaintTaxi.this.showDialog(ALERT_DIALOG);
}

From source file:org.planetmono.dcuploader.ActivityUploader.java

private void initViews() {
    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    if (wm.getDefaultDisplay().getOrientation() == 0)
        setContentView(R.layout.upload_portrait);
    else/*from  ww  w. j ava 2  s .  c  om*/
        setContentView(R.layout.upload_landscape);

    EditText uploadTarget = (EditText) findViewById(R.id.upload_target);
    EditText uploadTitle = (EditText) findViewById(R.id.upload_title);
    EditText uploadText = (EditText) findViewById(R.id.upload_text);
    Button uploadVisit = (Button) findViewById(R.id.upload_visit);
    Button uploadPhotoTake = (Button) findViewById(R.id.upload_photo_take);
    Button uploadPhotoAdd = (Button) findViewById(R.id.upload_photo_add);
    Button uploadPhotoDelete = (Button) findViewById(R.id.upload_photo_delete);
    CheckBox uploadEnclosePosition = (CheckBox) findViewById(R.id.upload_enclose_position);
    Button uploadOk = (Button) findViewById(R.id.upload_ok);
    Button uploadCancel = (Button) findViewById(R.id.upload_cancel);

    /* set button behavior */

    if (passThrough)
        uploadTarget.setClickable(false);
    else {
        uploadTarget.setClickable(true);
        registerForContextMenu(uploadTarget);
    }

    uploadTarget.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (!passThrough)
                openContextMenu(v);
        }
    });

    registerForContextMenu(uploadVisit);
    uploadVisit.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            openContextMenu(v);
        }
    });

    uploadPhotoTake.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            try {
                tempFile = File.createTempFile("dcuploader_photo_", ".jpg");
            } catch (IOException e) {
                Toast.makeText(ActivityUploader.this, " ??   .",
                        Toast.LENGTH_SHORT).show();

                tempFile = null;

                return;
            }

            Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            if (tempFile != null)
                i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));

            startActivityForResult(i, Application.ACTION_TAKE_PHOTO);
        }
    });

    uploadPhotoAdd.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.setType("image/*");
            i.addCategory(Intent.CATEGORY_DEFAULT);

            startActivityForResult(i, Application.ACTION_ADD_PHOTO);
        }
    });

    uploadPhotoDelete.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Gallery g = (Gallery) findViewById(R.id.upload_images);

            int pos = g.getSelectedItemPosition();
            if (pos == -1)
                return;

            contents.remove(pos);
            bitmaps.remove(pos);

            updateGallery();
            updateImageButtons();

            if (contents.size() == 0)
                pos = -1;
            else if (pos >= contents.size())
                --pos;

            g.setSelection(pos);
        }
    });

    uploadOk.setOnClickListener(proceedHandler);

    uploadCancel.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });

    uploadEnclosePosition.setChecked(formLocation);

    uploadEnclosePosition.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            locationEnabled = isChecked;

            queryLocation(isChecked);
        }
    });

    /* restore data when orientation changes */
    if (formGallery != null) {
        if (target != null) {
            uploadTarget.setText(formGallery);
            formGallery = null;
        }
    }

    if (formTitle != null) {
        uploadTitle.setText(formTitle);
        formTitle = null;
    }

    if (formBody != null) {
        uploadText.setText(formBody);
        formBody = null;
    }

    updateImageButtons();
    updateGallery();
}