We are dealing with the code from a course that loads an image. We are trying to do this with an Emulator API 26 Play Store active We have no jpg pictures on the emulator. The Device File Explore will let us Upload a jpg. We have tried various folders with no luck.
Our question is where to Upload the jpg to in the Device File Explore?
Code is Kotlin and the upload method is posted below
fun onChooseImage(view:View){
val intent = Intent()
intent.type = "image/*"
intent.action = Intent.ACTION_GET_CONTENT
val chooser = Intent.createChooser(intent,"Choose Image for Habit")
startActivityForResult(chooser,CHOOSE_IMAGE_REQUEST)
Log .d(TAG,"Image was sent" )
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if(requestCode == CHOOSE_IMAGE_REQUEST && resultCode == Activity.RESULT_OK
&& data != null && data.data != null){
Log.d(TAG,"An Image WAS Choosen")
val bitmap = tryReadBitmap(data.data)
bitmap?.let {
ivIcon.setImageBitmap(bitmap)
Log.d(TAG,"We Updated and Read Bitmap")
}
}
}
private fun tryReadBitmap(data: Uri?): Bitmap?{
return try{
MediaStore.Images.Media.getBitmap(contentResolver,data)
}catch (e:IOException){
e.printStackTrace()
null
}
}
And we are using Cold Boot on the emulator.
We have looked at other posts that suggest you can not use the emulator camera to save pictures to the emulator. Does this mean we need a real device to test this code?
Grendel's answer is workable but I would like to provide a less intensive set of steps
1. Load the app in question
2. Open AVD manager and select the little down icon next to the Emulator your using
3. Click on Wipe Data (suggestion keep Emulator setting Quick Boot) <- other topic
4. Store your jpg in this path Storage->Self->Primary-DCIM
5. This is done by RIGHT click DCIM select Upload navigate to jpg
6. Close AVD manage
7. Run your app and select the same Emulator
It seems with the emulator you need to scan the emulator with Dev Tools BUT one other issue seems to pop up the cache for google play services and google play store needs to be cleared. In the processes of fixing this we tried so many fixes not sure of all the steps in order. As for where to upload the jpg that we are sure of use this path with
/mnt/sdcard/DCIM/water.jpg When you get to DCIM right click it and select Upload
Here is a link that may help HELP LINK
Related
I would like to know how to open a link from a simple app that I have made to push a link from within the app from phone to open on the watch for example a link to google play store app to get downloaded on the smartwatch.
Thank you.
See the docs here https://developer.android.com/reference/androidx/wear/remote/interactions/RemoteActivityHelper
and an example here https://github.com/android/wear-os-samples/blob/d18c489ff415aa0fbb25c260e3aacdf50f7716e3/WearVerifyRemoteApp/Application/src/main/java/com/example/android/wearable/wear/wearverifyremoteapp/MainMobileActivity.kt
Log.d(TAG, "Number of nodes without app: " + nodesWithoutApp.size)
val intent = Intent(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setData(Uri.parse(PLAY_STORE_APP_URI))
// In parallel, start remote activity requests for all wear devices that don't have the app installed yet.
nodesWithoutApp.forEach { node ->
lifecycleScope.launch {
try {
remoteActivityHelper
.startRemoteActivity(
targetIntent = intent,
targetNodeId = node.id
)
.await()
I trying to create a whatsapp status saver in flutter. I trying to save the whatsapp status. I created a folder statuses in /storage/emulated/0/statuses/ and The process of copying goes well. But that Image is not shown in the gallery app.
So I even Tried storing it in DCIM/Camera still it doesn't show up there. But when the copy the same image using file explorer then that image shows up in gallery app. I think something is wrong with the image properties.
The code used to save is here.
saveFile(filePath) async {
String newFilename;
File originalFile = File(filePath);
Directory _directory = await getExternalStorageDirectory();
if (!Directory("/storage/emulated/0/statuses/").existsSync()) {
Directory("/storage/emulated/0/statuses/")
.createSync(recursive: false);
}
String curDate = DateTime.now().toString();
newFilename = "/storage/emulated/0/statuses/VIDEO-$curDate.jpg";
await originalFile.copy(newFilename).then((value) {
print("Saved: " + newFilename);
});
}
When you change a media, you should tell the device to re-scan. This image saver plugin will notify the Android OS about the media that is saved.
If you don't want the plugin, you can use platform channels to write native code yourself.
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
This issue is discussed here and here.
When finding random apk's online through urls, I can successfully download and install them, the user is prompted to ask if they want to install comes up. But when I upload the same apk's to Google drive, and then run the download url from Google drive, the apk's doesn't work. I get a "There was a problem while parsing the package" on the device screen. I put a log to see how much data is being downloaded. And it appears that the apk's being downloaded from google drive are barely the size of what the apk's should be. Around 50k instead of 4MB. I see a lot of questions online about this, but none have talked about Google play not sending the full file. Is there something I'm missing in order to get the full apk downloaded from Google drive? here is the code,
private void downloadApk(){
// checkVersion();
String extStorageDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString();
File folder = new File(extStorageDirectory);
folder.mkdirs();
File file = new File(folder, "app-debug.apk");
try {
file.createNewFile();
} catch (IOException e1) {
e1.printStackTrace();
}
DownloadApkTask downloadApkTask = new DownloadApkTask(APKURL,file);
downloadApkTask.execute();
}
public class DownloadApkTask extends AsyncTask<String, Void, Void> {
String fileURL;
File directory;
public DownloadApkTask(String fileURL,File directory) {
this.fileURL = fileURL;
this.directory = directory;
}
#Override
protected Void doInBackground(String... params) {
Log.v("DO in Back started","Started");
try {
FileOutputStream f = new FileOutputStream(directory);
URL u = new URL(fileURL);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.connect();
InputStream in = c.getInputStream();
byte[] buffer = new byte[1024];
int len1 = 0;
while ((len1 = in.read(buffer)) > 0) {
Log.v("PROGREsS", String.valueOf(len1));
f.write(buffer, 0, len1);
}
f.close();
directory.setReadable(true,false);
} catch (Exception e) {
System.out.println("exception in DownloadFile: --------"+e.toString());
e.printStackTrace();
}
return null;
}
#Override
protected void onPostExecute(Void stringReturn) {
super.onPostExecute(stringReturn);
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)+"/app-debug.apk");
Log.v("STARTING INSTALLATION","-----");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(intent);
}
}
Based from this page, parsing error occurs on app installment.
When you try to install an application suddenly a window pop-ups saying "there is a problem parsing the package" which means the application cannot be installed due to apk parser i.e. parsing issue.
There are several reasons why this parsing error occurs & definitely one of them is responsible for your parsing error:
File may be downloaded incompletely.
Application might be not suitable for your hardware or OS version.
Due to security issue settings
Corrupted APK file.
Follow the steps shown below for fixing the android parse error on your mobile devices:
Check Manifested app apk file.
Change the Andriomanifest.xml file to its default setting & also check the name of that file. If the original name of the file is “aap.apk” & if you renamed it as "app1.apk" then also it might cause an error. If you have some knowledge of coding, look into the app code if there is some problem with coding.
Security settings.
For the security purpose, the phone has an inbuilt setting that doesn't allow installing applications from a 3rd party provider other than mobile apps provided by play store. Don’t install an app from the non-trusted website. That might really risk your mobile.
Enable USB debugging.
Go to the settings >> Scroll down then, at last, you will see option “About device” select it.
Look for option “build number.”
Tap on “Build number” for 7 times.
You will see a message “you are now a developer.”
Once you enable to go back to settings
Choose “Developer options.”
Tick mark "USB debugging."
Corrupted App file.
The parse error may cause due to corrupted file too. In this case, download a new but complete APK file, & try again to install it again. This might help you.
Disable Antivirus.
If you have installed applications like antivirus & cleaner apps, then this can also prevent some apps installation. This prevention is due to the safety purpose of the handset. They block suspicious downloads from non-trusted sites. If you really want to install that app then disable the antivirus temporarily.
Clear cache cookies of play store.
Open google play store
Select sidebar & choose option “settings.”
In general settings, you will find out to “clear local search history.”
I have developped a Windows Phone plugin for my Unity application which enable me to open the Windows Phone gallery in order to select an image and get its physic path.
I've used this path to load the image in the application with a WWW object but I get this error
"Error. Operation has failed with error 0x80070005: access is denied."
The path is correct because I display it.
Here is my test code to load the image with the path.
IEnumerator loadImage()
{
this.guiText.text = filePath;
WWW www = new WWW(filePath);
yield return www;
if(www.error == null)
{
GameObject texture = GameObject.Find("UNITY");
if(texture != null)
{
texture.guiTexture.texture = www.texture;
}
}
}
Any help would be appreciated ! Thanks in advance !
I think you need to enable the permission for your application to give access to read files from the device.
Go to App Manifest file and check whether it is enabled or not, if not that will solve your problem.
I'm developing an app for Windows Phone 7 and I'm using a Phonegap template for it.
Everything looks perfect, but now I’m stuck trying to open a PDF file in the browser.
I tried the following but that doesn’t work because the url of the PDF exceeds the 2048 character limit (it’s a data url). This code runs after the deviceReady event was fired.
var ref = window.open('http://www.google.com', '_blank', 'location=no');
ref.addEventListener('loadstart', function () { alert(event.url); });
Now, I'm trying to save the PDF file to storage and then I'm trying to have it opened by the browser, but the browser doesn't show anything. I'm editing the InAppBrowser.cs code from cordovalib and I added the following lines before calling browser.Navigate(loc);
private void ShowInAppBrowser(string url)
{
IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
FileStream stream = store.OpenFile("test.pdf", FileMode.Create);
BinaryWriter writer = new BinaryWriter(stream);
var myvar = Base64Decode("the big data url");
writer.Write(myvar);
writer.Close();
if (store.FileExists("test.pdf")) // Check if file exists
{
Uri loc = new Uri("test.pdf", UriKind.Relative);
...
}
}
This code is returning the following error:
Log:"Error in error callback: InAppBrowser1921408518 = TypeError: Unable to get value of the property 'url': object is null or undefined"
I don’t wanna use ComponentOne.
Any help would be greatly appreciated!
You cannot open pdf files from the isolated storage in the default reader for PDF files. If the file is online e.g. it has a URI for it, you can use WebBrowserTask to open it since that will download and open the file in Adobe Reader.
On Windows Phone 8 you actually can open your own file in default file reader for that extension, but I am not sure how that will help you since you target PhoneGap and Windows Phone 7.
Toni is correct. You could go and try to build your own viewer (which would be the same thing as using C1, but with more time involved). I worked on a port of iTextSharp and PDFSharp for WP7, but neither of which are PDF Viewers. They are good for creating PDFs and parsing them some (but to render them there is more work involved). This has been a personal quest of mine, but honestly the best I have gotten is to be able to extract some images from the PDF (and none of the text)
try this
var installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
var assets = await installedLocation.GetFolderAsync("Assets");
var pdf = await assets.GetFileAsync("metro.pdf");
Windows.System.Launcher.LaunchFileAsync(pdf);
This worked correctly on my Device.