Java Code Examples for com.sdsmdg.tastytoast.TastyToast#makeText()

The following examples show how to use com.sdsmdg.tastytoast.TastyToast#makeText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateDownloadService.java    From v9porn with MIT License 6 votes vote down vote up
private void installApk(String path) {

        File file = new File(path);
        Uri uri;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            uri = FileProvider.getUriForFile(getApplicationContext(), BuildConfig.APPLICATION_ID+".fileprovider", file);
            //兼容8.0
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                boolean hasInstallPermission = getPackageManager().canRequestPackageInstalls();
                if (!hasInstallPermission) {
                    TastyToast.makeText(getApplicationContext(), "请在设置中打开允许安装未知来源", TastyToast.LENGTH_LONG,TastyToast.ERROR);
                    startInstallPermissionSettingActivity();
                    return;
                }
            }
        } else {
            uri = Uri.fromFile(file);
        }
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/vnd.android.package-archive");
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(intent);
    }
 
Example 2
Source File: BaseAppCompatActivity.java    From v9porn with MIT License 5 votes vote down vote up
protected void showMessage(String msg, int type) {
    //因为时在onDestroy 才取消的请求,初步断定又可能就是在那么微妙的一瞬间发生了
    //android.view.WindowManager$BadTokenException · Unable to add window -- token android.os.BinderProxy@53d6ca9 is not valid; is your activity running? 如果activity正在销毁则可能引发
    if (!isFinishing()) {
        TastyToast.makeText(getApplicationContext(), msg, TastyToast.LENGTH_SHORT, type);
    }
}
 
Example 3
Source File: PhotoImageActivity.java    From v9porn with MIT License 4 votes vote down vote up
private void showMessage(String s, int error) {
    TastyToast.makeText(this,s,TastyToast.LENGTH_SHORT,error);
}
 
Example 4
Source File: PhotoImageActivity.java    From v9porn with MIT License 4 votes vote down vote up
private void showMessage(String s, int error) {
    TastyToast.makeText(this,s,TastyToast.LENGTH_SHORT,error);
}