My application opens text files.

That it was suggested when choosing "than to open a file", I made changes to the manifest, everything is ok.

But how to transfer the file address to the application I can not figure it out.

Did that and got what I wanted

    1 answer 1

    Https://developer.android.com/training/sharing/send

    UPD:
    How to accept data:

    Bundle b = getIntent().getExtras(); String filePath = b.getString("filePath"); if(filePath != null) { //ваш код } 

    How to send data:

     Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage); shareIntent.setType("image/*"); startActivity(Intent.createChooser(shareIntent, "Chose app:")); 
    • So why do I need these links to documentation how to send data from my application and call some intent ?. I asked for help to write the syntax correctly, and not to send me to learn the principle of action. I understand in general terms, but I can not write exactly that. Your link is not about that. I just need to do so that the user can open the file with my application. The user chooses a file, he is offered my application, he chooses it, it starts (it works) and then you have to somehow inform my application of the file address - Evgeny Stoichkov
    • one
      1. I had the same question as you, and the documentation on the link helped me completely in solving my question. 2. The essence is the following: if you want to call your application, then you need to transfer data to the intent (in your case, a link to the file), and get this link in your own bundle. 3. tried to help. - Astend Sanferion pm
    • Thank you of course. But ... Well, give the code a worker, if you know how)). I do not need the essence. I will understand the essence of the working piece of code, and then I can deal with similar tasks. I do not know very well the syntax and often misunderstand what I could change for myself. Personally, when I answer people on development issues in those areas where I am an expert, I simply give a ready-made solution so that they can copy and paste and understand. - Evgeny Stoichkov
    • one
      updated, look - Astend Sanferion
    • okay. I paraphrase. I have only one main Activity in which there is @Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.mylayout); } Where do I need to write which piece of code that determines that the application was called to open the file and get the name of this file? - Evgeny Stoichkov