java.lang.IllegalArgumentException: Parameter specified as non-null is null - java

getting java.lang.IllegalArgumentException: Parameter specified as non-null is null, with Camera Intent in Kotlin, but in JAVA this code is working.
I am very confusing why It is happening.
after Capture Image I am getting this error and crashng app.
try {
val imageFile = createImageFile()
val callCameraIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
if(callCameraIntent.resolveActivity(packageManager) != null) {
val authorities = packageName + ".provider"
val imageUri = FileProvider.getUriForFile(this, authorities, imageFile)
callCameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri)
startActivityForResult(callCameraIntent, CAMERA_REQUEST_CODE)
}
} catch (e: IOException) {
Toast.makeText(this, "Could not create file!", Toast.LENGTH_SHORT).show()
}
fun createImageFile(): File {
val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date())
val imageFileName: String = "JPEG_" + timeStamp + "_"
val storageDir: File = getExternalFilesDir(Environment.DIRECTORY_PICTURES)
if(!storageDir.exists()) storageDir.mkdirs()
val imageFile = File.createTempFile(imageFileName, ".jpg", storageDir)
imageFilePath = imageFile.absolutePath
return imageFile
}
09-30 13:32:19.145 6918-6918/app.smallbites.com.smallbites E/AndroidRuntime: FATAL EXCEPTION: main
Process: app.smallbites.com.smallbites, PID: 6918
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1001, result=-1, data=null} to activity {app.smallbites.com.smallbites/app.smallbites.com.smallbites.ui.onboarding.AddKidActivity}: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter data
at android.app.ActivityThread.deliverResults(ActivityThread.java:4268)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6501)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter data
at app.smallbites.com.smallbites.ui.onboarding.AddKidActivity.onActivityResult(Unknown Source:37)

The problem is in your data you wanna transmit to. You put Null object when it should be NonNull
Check the next things:
Permission for camera
Permission for storage (read/write)
Check the place where do you want to store your file, usually, people are fighting with issues internal/external storage.
Also, please, check if your question exists. I guess I found a similar problem.
android camera : Failure delivering result ResultInfo{who=null, request=0, result=-1, data=null} to activity

Related

save audio file using MediaStore API

I'm trying to create the URI but my app crached.this is my code.
ContentValues values1 = new ContentValues(1);
values1.put(MediaStore.Audio.Media.DISPLAY_NAME, "My Song.mp3");
ContentResolver resolver = getApplicationContext().getContentResolver();
audiouri = resolver.insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values1);
And this is the error that i got.
2021-09-20 00:22:22.963 24197-24197/com.example.voicetest E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.voicetest, PID: 24197
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.lastIndexOf(int)' on a null object reference
at android.os.Parcel.createException(Parcel.java:1956)
at android.os.Parcel.readException(Parcel.java:1918)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
at android.content.ContentResolver.insert(ContentResolver.java:1587)
at com.example.voicetest.MainActivity$1.onClick(MainActivity.java:148)
at android.view.View.performClick(View.java:7044)
at android.view.View.performClickInternal(View.java:7017)
at android.view.View.access$3200(View.java:784)
at android.view.View$PerformClick.run(View.java:26596)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6819)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:497)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:912)
UPDATE
I added this code and it's work fine, but getContentResolver().insert() return null
File directory = getExternalFilesDir(Environment.DIRECTORY_MUSIC);
values.put(MediaStore.Audio.AudioColumns.DATA, "${directory}${song?.title}");
File directory = getExternalFilesDir(Environment.DIRECTORY_MUSIC);
values.put(MediaStore.Audio.AudioColumns.DATA, "${directory}${song?.title}");
I added this code and it's work fine, but getContentResolver().insert() return null

E/GraphResponse: Unsupported get request. Android Studio facebook login

I have problem with Facebook login app. I was fallowing this tutorial . I took every step and on the end i converted MainAcktivity into kotlin file. Application after login in or logout is stopping.
and I'm receiving follow error in Logcat:
2021-05-22 19:23:12.963 9521-9545/com.example.XXX_login E/GraphResponse: {HttpStatus: 400, errorCode: 100, subErrorCode: 33, errorType: GraphMethodException, errorMessage: Unsupported get request. Object with ID '111111111111111' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api}
2021-05-22 19:23:46.065 9521-9521/com.example.XXX_login E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.XXX_login, PID: 9521
java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter oldAccessToken
at com.example.XXX_login.MainActivity$accessTokenTracker$1.onCurrentAccessTokenChanged(Unknown Source:2)
at com.facebook.AccessTokenTracker$CurrentAccessTokenBroadcastReceiver.onReceive(AccessTokenTracker.java:110)
at androidx.localbroadcastmanager.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:313)
at androidx.localbroadcastmanager.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:121)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Here is my MainActivity.kt file:
package com.example.XXX_login
import com.facebook.FacebookSdk
import com.facebook.appevents.AppEventsLogger
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.facebook.*
import com.facebook.login.LoginManager
import com.facebook.login.LoginResult
import com.facebook.login.widget.LoginButton
import org.json.JSONException
import com.squareup.picasso.Picasso as Picasso1
//import java.util.*
class MainActivity : AppCompatActivity() {
private var callbackManager: CallbackManager? = null
private lateinit var loginButton: LoginButton
private var imageView: ImageView? = null
private var textView: TextView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
loginButton = findViewById(R.id.login_button)
textView = findViewById(R.id.tv_name)
imageView = findViewById(R.id.tv_profilePic)
callbackManager = CallbackManager.Factory.create()
//permisions do logowania
loginButton.setPermissions(
listOf(
"user_gender",
"email",
"user_location",
"user_birthday"
)
)
loginButton.registerCallback(callbackManager, object : FacebookCallback<LoginResult?> {
override fun onSuccess(loginResult: LoginResult?) {
Log.d("Demo", "Zalogowano!")
}
override fun onCancel() {
Log.d("Demo", "Wylogowano")
}
override fun onError(error: FacebookException) {
Log.d("Demo", "Bład logowania:")
}
})
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
callbackManager!!.onActivityResult(requestCode, resultCode, data)
super.onActivityResult(requestCode, resultCode, data)
val graphRequest =
GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken()) { `object`, response ->
//tworzenie pliku JSON z pobieranymi przez Graph danymi
Log.d("Demo", `object`.toString())
try {
val name = `object`.getString("name")
val pic = `object`.getJSONObject("picture").getJSONObject("data").getString("url")
textView!!.text = name
Picasso1.get().load(pic).into(imageView)
} catch (e: JSONException) {
e.printStackTrace()
}
}
val bundle = Bundle()
//informacjie pozyskiwane z facebooka= defaultowe i na podstawie wcześniej wydanych permissions
bundle.putString(
"fields",
"gender, name, first_name, last_name, email, birthday, location, picture"
)
graphRequest.parameters = bundle
graphRequest.executeAsync()
}
//tracker do sprawdzania czy użytkownik jest zalogowany, jestli token sie zmieni to wywowała sie ta metoda
//wylogowywanie sie
var accessTokenTracker: AccessTokenTracker = object : AccessTokenTracker() {
override fun onCurrentAccessTokenChanged(
oldAccessToken: AccessToken,
currentAccessToken: AccessToken
) {
if (currentAccessToken == null) {
LoginManager.getInstance().logOut()
textView!!.text = ""
imageView!!.setImageResource(0)
}
}
}
override fun onDestroy() {
super.onDestroy()
accessTokenTracker.stopTracking()
}
}
I had have read in the internet for answer for this problem but i've could't find something that could work.
This is because in Kotlin you have to specify the variable as nullable if it will be null in any case.
The error is in this function
var accessTokenTracker: AccessTokenTracker = object : AccessTokenTracker() {
override fun onCurrentAccessTokenChanged(
oldAccessToken: AccessToken,
currentAccessToken: AccessToken
) {
if (currentAccessToken == null) {
LoginManager.getInstance().logOut()
textView!!.text = ""
imageView!!.setImageResource(0)
}
}
}
here in the onCurrentAccessTokenChanged() function you are expecting the currentAccessToken to be null, but you have not made currentAccessToken as nullable hence it will fail and crash. Since only nullable elements can get null value assigned after initialisation in Kotlin. Therefore here you can make the variables as nullable and the problem will be solved.
You can make any variable as nullable like this
currentAccessToken : Type? , where the Type can be Int, String or any supported or custom type.
var accessTokenTracker: AccessTokenTracker = object : AccessTokenTracker() {
override fun onCurrentAccessTokenChanged(
oldAccessToken: AccessToken?,
currentAccessToken: AccessToken?
) {
if (currentAccessToken == null) {
LoginManager.getInstance().logOut()
textView!!.text = ""
imageView!!.setImageResource(0)
}
}
}
This will solve your problem.
It is always recommended that you make the variables as Nullable if you think that the variable might accommodate null at any time in the future in any case to avoid such crashes.

Getting list of device ringtones, weird error on 1 emulator?

I get the following error:
java.lang.IllegalArgumentException: Volume external_primary not found
But this only happens on 1 emulator I am running. It works fine on other emulators or my physical android phone.
Here is the code I am trying to run that causes the issue:
private fun listRingtones(): LinkedHashMap<String, String> {
var manager = RingtoneManager(this)
manager.setType(RingtoneManager.TYPE_NOTIFICATION)
var cursor: Cursor = manager.cursor
var list = LinkedHashMap<String, String>()
while (cursor.moveToNext()) {
var title: String = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX)
var ringtoneURI: Uri = manager.getRingtoneUri(cursor.position)
// Place the title and uri into a hashMap
list.put(title, ringtoneURI.toString())
}
return list
}
Specifically the debugger craps out on this line:
var cursor: Cursor = manager.cursor
Anyone seen anything like this or what could be the cause?
Here is the full error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.package.mypackage, PID: 7370
java.lang.IllegalArgumentException: Volume external_primary not found
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:423)
at android.content.ContentResolver.query(ContentResolver.java:944)
at android.content.ContentResolver.query(ContentResolver.java:880)
at android.content.ContentResolver.query(ContentResolver.java:836)
at android.app.Activity.managedQuery(Activity.java:3111)
at android.media.RingtoneManager.query(RingtoneManager.java:646)
at android.media.RingtoneManager.getMediaRingtones(RingtoneManager.java:579)
at android.media.RingtoneManager.getMediaRingtones(RingtoneManager.java:571)
at android.media.RingtoneManager.getCursor(RingtoneManager.java:437)
at com.package.mypackage.NewReminderActivity.listRingtones(NewReminderActivity.kt:899)
at com.package.mypackage.NewReminderActivity.access$listRingtones(NewReminderActivity.kt:61)
at com.package.mypackage.NewReminderActivity$showSoundMenuAlert$2.onClick(NewReminderActivity.kt:1120)
at android.view.View.performClick(View.java:7140)
at android.view.View.performClickInternal(View.java:7117)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27351)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

make simple code but app has stopping work in kotlin

l am try to learn kotlin language , and the first app to me is take data fro json array . but the problem is when start to debug app l got FATAL EXCEPTION: main and app has stopping working . In my Android App, I desgin the following json data construction
my code is :
package com.example.ali.test
import android.os.AsyncTask
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_main.view.*
import org.json.JSONArray
import org.json.JSONObject
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URL
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val url = "https://mysafeinfo.com/api/data?list=presidents&format=json"
Download().execute(url)
}
// full class for json api
inner class Download : AsyncTask<String,String,String>(){
override fun onPreExecute() {
}
// for build connection
override fun doInBackground(vararg p0: String?): String{
try {
val url = URL(p0[0])
val urlConnect = url.openConnection() as HttpURLConnection
urlConnect.connectTimeout = 700
val inputStream = urlConnect.inputStream
val dataJsonAsStr = covertStreamToString(urlConnect.inputStream)
publishProgress(dataJsonAsStr)
} catch (e: Exception){
}
return ""
}
// for get items from json api
override fun onProgressUpdate(vararg values: String?) {
}
override fun onPostExecute(result: String?) {
super.onPostExecute(result)
handleJson(result)
}
}
fun handleJson (jsonString: String?){
val jsonArray = JSONArray(jsonString)
val list = ArrayList<FlightShdu>()
var x = 0
while (x < jsonArray.length()){
val jsonObject = jsonArray.getJSONObject(x)
list.add(FlightShdu(
jsonObject.getInt("id"),
jsonObject.getString("nm")
))
x++
}
val adapter = ListAdapte(this#MainActivity,list)
flightShdu_list.adapter = adapter
}
// for connection api
fun covertStreamToString (inputStream: InputStream): String {
val bufferReader = BufferedReader(InputStreamReader(inputStream))
var line:String
var allString:String=""
try {
do{
line=bufferReader.readLine()
if (line!=null)
allString+=line
}while (line!=null)
bufferReader.close()
}catch (ex:java.lang.Exception){}
return allString;
}
}
error in console :
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ali.test, PID: 24738
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) 
Caused by: org.json.JSONException: End of input at character 0 of
at org.json.JSONTokener.syntaxError(JSONTokener.java:449)
at org.json.JSONTokener.nextValue(JSONTokener.java:97)
at org.json.JSONArray.<init>(JSONArray.java:92)
at org.json.JSONArray.<init>(JSONArray.java:108)
at com.example.ali.test.MainActivity.handleJson(MainActivity.kt:68)
at com.example.ali.test.MainActivity$Download.onPostExecute(MainActivity.kt:59)
at com.example.ali.test.MainActivity$Download.onPostExecute(MainActivity.kt:27)
at android.os.AsyncTask.finish(AsyncTask.java:660)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) 
any one have any idea please ?
Your doInBackground() always returns an empty string, "". This empty string will be passed as the parameter to onPostExecute, which in turns uses this empty string as a parameter to handleJson. When you try to create a JSON array from this empty string it throws an exception at index 0, as it doesn't have any more data and it's not a valid json.
You need to return the result of the network call from doInBackground() instead of an empty string.
**
Use your code like this example below:
**
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val s = tvDisplay.text.toString()
btnOk.setOnClickListener {
Download().execute(s)
}
}
inner class Download : AsyncTask<String, Void, Void>() {
override fun doInBackground(vararg ss: String?): Void? {
validate(ss[0]!!)
return null
}
}
private fun validate(s:String) {
if(s.isNotEmpty()){
runOnUiThread {
Toast.makeText(this, "Working :)", Toast.LENGTH_SHORT).show()
}
}
else{
runOnUiThread {
Toast.makeText(this, "Not Working :(", Toast.LENGTH_SHORT).show()
}
}
}
}

Android Dropbox API v1 upload file and get shared link of this file

I have uploaded file and when I try to get the shared link then it gives NullPointerException.
FileInputStream fis = new FileInputStream(mFile);
String path = mPath + mFile.getName();
DropboxAPI.Entry response = mApi.putFile(path, fis,
mFile.length(), null, new ProgressListener() {
#Override
public long progressInterval() {
// Update the progress bar every half-second or so
return 500;
}
#Override
public void onProgress(long bytes, long total) {
publishProgress(bytes);
}
});
Log.i("DbExampleLog", "The uploaded file's rev is: " + response.rev);
if (response != null) {
mErrorMsg=response.path;
Log.e("DbExampleLog", "*****"+response.path+" The uploaded file's rev is: " + response.rev);
DropboxAPI.DropboxLink shareLink = mApi.share(response.path);
Log.e("DbExampleLog", "*****"+shareLink+" The uploaded file's rev is: " + response.rev);
if(shareLink!=null) {
if(shareLink.url!=null) {
Log.e("Null error URL*****",""+shareLink.url);
Log.e("Null error URL*****",""+getShareURL(shareLink.url));
String shareAddress = getShareURL(shareLink.url).toString();
Log.e("DbExampleLog", "URL -" + shareAddress + "*****" + response.path + " The uploaded file's rev is: " + response.rev);
}
else
Log.e("Null error URL*****",""+shareLink.url);
}
else{
Log.e("Null error*****",""+shareLink);
}
return true;
}
It returns like -
12-05 12:09:09.207 7335-7502/com.trucker.gtd.satyaki.dropboxintegrationapiv1 E/DbExampleLog: *****/1480919937073.jpg The uploaded file's rev is: 2ef4a7ca38e
12-05 12:09:10.966 7335-7502/com.trucker.gtd.satyaki.dropboxintegrationapiv1 E/DbExampleLog: *****com.dropbox.client2.DropboxAPI$DropboxLink#d9d5da1 The uploaded file's rev is: 2ef4a7ca38e
12-05 12:09:10.966 7335-7502/com.trucker.gtd.satyaki.dropboxintegrationapiv1 E/Null error URL*****: https://db.tt/ru6e39XK0
12-05 12:09:12.457 7335-7502/com.trucker.gtd.satyaki.dropboxintegrationapiv1 E/Null error URL*****: null
12-05 12:09:13.520 7335-7502/com.trucker.gtd.satyaki.dropboxintegrationapiv1 E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.trucker.gtd.satyaki.dropboxintegrationapiv1, PID: 7335
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toString()' on a null object reference
at com.trucker.gtd.satyaki.dropboxintegrationapiv1.UploadFile.doInBackground(UploadFile.java:147)
at com.trucker.gtd.satyaki.dropboxintegrationapiv1.UploadFile.doInBackground(UploadFile.java:63)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:761) 
12-05 12:09:13.645 1248-1248/? E/EGL_emulation: tid 1248: eglCreateSyncKHR(1641): error 0x3004 (EGL_BAD_ATTRIBUTE)
12-05 12:09:13.796 2071-2205/com.android.launcher3 E/EGL_emulation: tid 2205: eglSurfaceAttrib(1146): error 0x3009 (EGL_BAD_MATCH)
12-05 12:09:14.006 1530-1640/system_process E/EGL_emulation: tid 1640: eglSurfaceAttrib(1146): error 0x3009 (EGL_BAD_MATCH)
12-05 12:09:14.304 7335-7335/com.trucker.gtd.satyaki.dropboxintegrationapiv1 E/WindowManager: android.view.WindowLeaked: Activity com.trucker.gtd.satyaki.dropboxintegrationapiv1.Main has leaked window DecorView#3bf9cac[] that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:417)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:331)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at android.app.Dialog.show(Dialog.java:316)
at android.app.AlertDialog$Builder.show(AlertDialog.java:1112)
at com.dropbox.client2.android.AuthActivity.checkAppBeforeAuth(AuthActivity.java:284)
at com.dropbox.client2.android.AndroidAuthSession.startAuthentication(AndroidAuthSession.java:213)
at com.trucker.gtd.satyaki.dropboxintegrationapiv1.Main.onActivityResult(Main.java:132)
at android.app.Activity.dispatchActivityResult(Activity.java:6915)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4049)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4096)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1516)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
12-05 12:09:14.310 7335-7335/com.trucker.gtd.satyaki.dropboxintegrationapiv1 E/WindowManager: android.view.WindowLeaked: Activity com.trucker.gtd.satyaki.dropboxintegrationapiv1.Main has leaked window DecorView#e8ad10a[] that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:417)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:331)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at android.app.Dialog.show(Dialog.java:316)
at com.trucker.gtd.satyaki.dropboxintegrationapiv1.UploadFile.<init>(UploadFile.java:98)
at com.trucker.gtd.satyaki.dropboxintegrationapiv1.Main.setLoggedIn(Main.java:144)
at com.trucker.gtd.satyaki.dropboxintegrationapiv1.Main.onResume(Main.java:168)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1269)
at android.app.Activity.performResume(Activity.java:6766)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3377)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3440)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1510)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Mainly in this particular line-
getShareURL(shareLink.url)
Please suggest me why this error occur, but yesterday using this code it worked.
UPDATE CODE ASKED BY Greg
String getShareURL(String strURL) {
URLConnection conn = null;
String redirectedUrl = null;
try {
URL inputURL = new URL(strURL);
conn = inputURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
System.out.println("Redirected URL: " + conn.getURL());
Log.e("Get Redirected URL",""+conn.getURL());
redirectedUrl = conn.getURL().toString();
is.close();
} catch (MalformedURLException e) {
Log.e("TAG", "Please input a valid URL");
} catch (IOException ioe) {
Log.e("TAG", "Can not connect to the URL");
}
return redirectedUrl;
}
This code taken from Share file in Dropbox

Categories

Resources