Recent

Author Topic: Android Module Wizard  (Read 523848 times)

Segator

  • Jr. Member
  • **
  • Posts: 53
Re: Android Module Wizard
« Reply #1185 on: November 08, 2019, 04:54:37 pm »
@kordal, hi thats is good for fixed path but i am talking about convert a content uri from a intent activity like when you open an imagen file with your app the system send a uri string like content://media/external/images/media/112 but this content have a real file path like /storage/sdcard/Pictures/imagen.jpg so i want to convert it content uri to the real path

Segator

  • Jr. Member
  • **
  • Posts: 53
Re: Android Module Wizard
« Reply #1186 on: November 08, 2019, 05:06:10 pm »
I found this but is a java code  %) :
Code: Java  [Select]
  1. public class getRealPathUtil {
  2.  
  3.         @ @TargetApi(Build.VERSION_CODES.KITKAT)
  4.         public static String getRealPathFromURI_API19(Context context, Uri uri){
  5.                 String filePath = "";
  6.                 String wholeID = DocumentsContract.getDocumentId(uri);
  7.              String id = wholeID.split(":")[1];
  8.  
  9.              String[] column = { MediaStore.Images.Media.DATA };    
  10.  
  11.              // where id is equal to            
  12.              String sel = MediaStore.Images.Media._ID + "=?";
  13.  
  14.              Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
  15.                                        column, sel, new String[]{ id }, null);
  16.              int columnIndex = cursor.getColumnIndex(column[0]);
  17.              if (cursor.moveToFirst()) {
  18.                  filePath = cursor.getString(columnIndex);
  19.              }
  20.              cursor.close();
  21.              return filePath;
  22.         }
  23.        
  24.        
  25.         public static String getRealPathFromURI(Context context, Uri contentUri) {
  26.                   Cursor cursor = null;
  27.         try {
  28.             String[] proj = { MediaStore.Images.Media.DATA };
  29.             cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
  30.             cursor.moveToFirst();
  31.            int column_index = cursor.getColumnIndex(proj[0]);
  32.             String path = cursor.getString(column_index);
  33.             return path;
  34.         } finally {
  35.             if (cursor != null) {
  36.                 cursor.close();
  37.             }
  38.         }
  39.                   return result;  
  40.         }
  41.        
  42. }
  43.  
can be implemented in LAMW?

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: Android Module Wizard
« Reply #1187 on: November 08, 2019, 08:02:04 pm »
Quote
can be implemented in LAMW?

Yes!  i will implement them as jForm methods...

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

kordal

  • New Member
  • *
  • Posts: 11
Re: Android Module Wizard
« Reply #1188 on: November 11, 2019, 01:09:18 am »
@jmpessoa, Have you looked at the source ? And then the post remained unanswered, suddenly did not notice the link)
« Last Edit: November 11, 2019, 01:11:16 am by kordal »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: Android Module Wizard
« Reply #1189 on: November 11, 2019, 03:07:13 am »

Hi, kordal!

Yes!

Great work!

I will commit your code!  [as soon as possible!]

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: Android Module Wizard
« Reply #1190 on: November 11, 2019, 05:41:18 am »
@Segator
Quote
I found this but is a java code

Done!

implement as jForm methods...

Code: Pascal  [Select]
  1. var
  2.   Uri: jObjectRef;
  3. begin
  4.      ....................
  5.  
  6.      ShowMessage(Self.GetRealPathFromURI(Uri));
  7.  
  8.      ............................................
  9. end;
  10.  
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Segator

  • Jr. Member
  • **
  • Posts: 53
Re: Android Module Wizard
« Reply #1191 on: November 11, 2019, 03:20:09 pm »
@Segator
Quote
I found this but is a java code

Done!

implement as jForm methods...

Code: Pascal  [Select]
  1. var
  2.   Uri: jObjectRef;
  3. begin
  4.      ....................
  5.  
  6.      ShowMessage(Self.GetRealPathFromURI(Uri));
  7.  
  8.      ............................................
  9. end;
  10.  

Thats is great!, very thank to you.

kordal

  • New Member
  • *
  • Posts: 11
Re: Android Module Wizard
« Reply #1192 on: November 11, 2019, 11:01:07 pm »
Hi, jmpessoa! It`s ok, thanks. I modified my example and adding new (SetRotate) overload method.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1470
Re: Android Module Wizard
« Reply #1193 on: November 12, 2019, 01:53:37 am »

Quote
I modified my example ....

In time!

Commited!

Thank you
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

kordal

  • New Member
  • *
  • Posts: 11
Re: Android Module Wizard
« Reply #1194 on: November 12, 2019, 09:02:18 pm »
Very well! good news, thank you :)