77
77
import java .io .InputStream ;
78
78
import java .io .InputStreamReader ;
79
79
import java .io .OutputStream ;
80
+ import java .net .URI ;
80
81
import java .net .URLDecoder ;
81
82
import java .nio .ByteBuffer ;
82
83
import java .nio .ByteOrder ;
@@ -466,11 +467,18 @@ private void handleIncomingIntent(Intent intent) {
466
467
String fileName ;
467
468
468
469
Project externalProject = null ;
470
+ Uri uri = null ;
469
471
470
- if (intent .getData () != null && intent .getData ().getEncodedPath () != null ) {
471
- isOpenByOtherApp = true ;
472
+ String action = intent .getAction ();
473
+ String type = intent .getType ();
474
+ if ( Intent .ACTION_SEND .equals (action ) && intent .hasExtra ( Intent .EXTRA_STREAM )) {
475
+ uri = (Uri ) intent .getParcelableExtra (Intent .EXTRA_STREAM );
476
+ } else if (intent .getData () != null && intent .getData ().getEncodedPath () != null ) {
477
+ uri = intent .getData ();
478
+ }
472
479
473
- Uri uri = intent .getData ();
480
+ if ( uri != null ) {
481
+ isOpenByOtherApp = true ;
474
482
String encodedPath = uri .getEncodedPath ();
475
483
476
484
String scheme = uri .getScheme ();
@@ -479,9 +487,7 @@ private void handleIncomingIntent(Intent intent) {
479
487
fileName = fileNameForFlashing (fullPathOfFile );
480
488
externalProject = fileName == null ? null : new Project (fileName , fullPathOfFile , 0 , null , false );
481
489
} else if (scheme .equals ("content" )) {
482
-
483
490
Cursor cursor = null ;
484
-
485
491
try {
486
492
cursor = getContentResolver ().query (uri , null , null , null , null );
487
493
@@ -541,7 +547,7 @@ private void handleIncomingIntent(Intent intent) {
541
547
if ( mProgramToSend != null ) {
542
548
startBluetoothForFlashing ();
543
549
} else {
544
- if (isOpenByOtherApp ) {
550
+ if ( isOpenByOtherApp ) {
545
551
Toast .makeText (this , "Not a micro:bit HEX file" , Toast .LENGTH_LONG ).show ();
546
552
onFlashComplete ();
547
553
}
0 commit comments