我打算开发LINE图片分享功能。我正在尝试使用 LINE://msg/image/$path 执行此操作,但我收到错误传达“检查链接是否正确,或更新...”的错误。为什么?请帮我。
package com.tsunagari.joynet_stamp
import android.annotation.SuppressLint
import android.content.Intent.*
import android.content.pm.PackageManager
import android.os.Build
import androidx.annotation.NonNull
import androidx.annotation.RequiresApi
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import java.io.File
class MainActivity: FlutterActivity() {
private val methodChannel = "com.tsunagari.joynet_stamp/line_share"
@SuppressLint("WrongConstant")
@RequiresApi(Build.VERSION_CODES.R)
override fun configureFlutterEngine(@NonNull flutterEngine:FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, methodChannel).setMethodCallHandler {
call, result ->
// Note: this method is invoked on the main thread.
if( call.method == "lineShare" ) {
try {
context.packageManager.getApplicationInfo("jp.naver.line.android", 128)
val path: String = call.argument<String>("path") as String
val file = File(path)
val filePath: String = file.path
print(filePath)
if( file.exists()){
println("exists")
}
else{
println("empty")
}
// val path = Environment.getExternalStorageDirectory().absolutePath + "/myapp/aaa.jpg";
val lineString = "line://msg/image/$filePath"
val intent = parseUri(lineString, URI_INTENT_SCHEME)
println(lineString)
//val intent = Intent()
//intent.action = Intent.ACTION_VIEW
//intent.data = Uri.parse(lineString)
startActivity(intent)
// val lineString = "line://msg/text/OOOKKKMMM"
// val intent = parseUri(lineString, URI_INTENT_SCHEME)
// context.startActivity(intent)
result.success("welcome!")
} catch (e: PackageManager.NameNotFoundException) {
result.error("400", e.message, e.localizedMessage)
}
}
}
}
}