How to sharea file from Android app to other device via bluetooth? - android

Hi,
I'm developing an app on android studio that allows me to send a txt file, which I create from the EditText, to another device via Bluetooth, my code is this:
Intent intent=new Intent(Intent.ACTION_SEND);
Uri text=Uri.parse(Environment.getExternalStorageDirectory().toString()+"/doc/mytext.txt");
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_STREAM, text);
startActivity(Intent.createChooser(intent,BLUETOOTH_SERVICE));
I can share the file via whatsapp without problems but via bluetooth I have the following errors:
[
on:
Bluetooth file sent:
Successful operations: 0, Non-tripping operations: 4.
under:
Bluetooth: file Unknown file not sent]1
unknown file
Laptop ..
The request could not be correctly managed.
I have set the following permissions on the Android Manifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

Related

Error in uploading an image from your phone

When I upload an image from my phone to the app, I get the error:
Unknown bits set in runtime_flags: 0x8000
and
Access denied finding property
At the same time, everything loads normally from Google drive.
The permissions are available in the manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Updated: the file upload is triggered on the third attempt...

Internet Permission Error in Android

I made a simple currency converter application for android. For taking latest currency rates from internet, i need to give permission to connect internet from manifest file.
I added this line to manifest file before
<uses-permission android:name="android.permission.INTERNET" />
I created an apk file of the application and installed it to my phone. Android version of my phone is 4.4.2 and when my wifi is open it gives error. When my wifi is closed the application is opened but can't take xml data. I installed apk file to phone of my friend and anroid version of his phone is 6.0. It works in his phone without any problem.
I added this lines to manifest file
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
but it didn't work in this way as well.
In build gradle file compileSdkVersion 23, minSdkVersion 19, targetSdkVersion 19.
Could you please help me to solve this problem?
Thank you

Android : open failed eacces permission denied

i am new to android. i have tried this code
in manifest file i wrote this
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
in java code
File sdcard = Environment.getExternalStorageDirectory();
//Get the text file
File file = new File(sdcard,"store.txt");
but i am getting above exception
i want to perform file read and write operations and i am using version 4.4.2.
i am getting this error
06-14 02:19:44.491: D/Shopping Cart(1700): open failed: EACCES (Permission denied)
Under kitkat your app can only write to an app specific directory on the -removable- sd card. You get possible directories using getExternalFilesDirs().
Is your permission is right place in manifest file as
<application>
...
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
</manifest>
Edit
Try to edit the Emulator
go to android virtual device manager and then edit the emulator
set say 100 MB for Sd card for the respected emulator and say Ok
save and close emulator and start
path saved in DDMS is mnt/sdcard/yourfilename
it worked for me the app is not giving Error and is working
Please see more at this link Cannot Write to sdcard in Android emulator
and this link Guide to Emulating an SD Card Using the Google Android Emulator

Install apk from java code without user confirmation

I want to install an apk file from java code. I want to do this silently without any action from user. I try this code ..
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(files[i].toString())), "application/vnd.android.package-archive");
startActivity(intent);
It works but wants the user to confirm the installation.
I try
Process p;
p = Runtime.getRuntime().exec("pm -s install "+files[i].toString()+"\"");
but doesn't work
i have given these permissions
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" />

I want update my android app when new version find in my web server from my web server but its not installing

Inside my android application I have created a service that will check on my web server, if new version application will found it will update my application.
but I cannot install or my installation is unsuccessfull untill i uninstall the privious version.
my new version installation code is:
Intent promptInstall = new Intent(Intent.ACTION_VIEW);
promptInstall.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() +"/apks/PHS_TKS_v3.apk")), "application/vnd.android.package-archive");
promptInstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(promptInstall);
and user permission in manifest is:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_OWNER_DATA" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INSTALL_PACKAGES"/>
<uses-permission android:name="android.permission.RESTART_PACKAGES"/>
I am trying to install new version apk not same version
If i install manually its not installing if older version is installed.
The error msg "an existing package by the same name with a conflicting signature is already installed" means, that you have the application installed already, but it was built with a different signature.
If you were building and debugging in eclipse, then it pushed the apk to your phone with the debug or test keys.
You need to uninstall the app, then installed a version that was built using your custom keystore

Categories

Resources