Is it possible to create an App which can receive images without using any permissions or buttons on the receiving device? I would like to show these images instantly on the device (device has no touchscreen so I can't accept any permissions). The device has only WiFi and no Bluetooth.
I was thinking about choosing a image from my smartphone, connect it to the target device, send it via WiFi-Direct(P2P) and display it on the device.
Is something like that possible? All the tutorials to sending/receiving images always have the issue that buttons or permissions are necessary.
Yes you can achieve that simply if you set an ImageView that will load the image from an URL (for example). Could be your website or a share site that has a static link reference.
It could look like that:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageView);
Glide.with(this).load("https://your-image.png").into(imageView);
}
Use this implemtation in your build.gradle:
dependencies {
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
}
And in the other build.gradle folder:
repositories {
google()
mavenCentral()
}
Here is a example video written in kotlin.
And also the glide feature explained at github.
Related
I have a working implementation of Googles PanoramaAPI in my Application. Unfortunately, the implementation stopped working on Android 11.
The implementation looks like the following:
Uri uri = Uri.fromFile(file);
Panorama.PanoramaApi.loadPanoramaInfoAndGrantAccess(mClient, uri).setResultCallback(
new ResultCallback<PanoramaResult>() {
#Override
public void onResult(PanoramaResult result) {
if (result.getStatus().isSuccess()) {
Intent viewerIntent = result.getViewerIntent();
Log.i(TAG, "found viewerIntent: " + viewerIntent);
if (viewerIntent != null) {
startActivity(viewerIntent);
finish();
}
} else {
Log.e(TAG, "error: " + result);
}
}
});
Following Situation:
When I make a panorama image on my smartphone and load it into the given implementation, it works. The image get's loaded from /storage/emulated/0/DCIM/Camera/*.jpg and the panorama view is shown without a problem.
When I Upload the same image on a server and download it through the app, the image get's stored on /storage/emulated/0/Android/data/<applicationId>/files/*.jpg. Unfortunately, the panorama view is not able to load the image and the viewerIntent is allways null.
For me, it looks like a permission problem on Android 11, but I don't know how to fix it. I don't want to download the image into a more public area of the phone. Does anyone has an idea how to fix it?
I suspect it is related to the introduction of Scoped Storage in Android 11, but I'm not sure.
I've managed to put together an alternative to the Panorama API using the VR Kit, which I've documented in my blog post with some code snippets.
The TLDR is this:
Replace your original ImageView with a VrPanoramaView
Use the VrPanoramaView's API to hide some options (optional)
Overlay an image button over the VrPanoramaView and use it to toggle between gyroscopic and touch modes
Use touch interception to support pinch zoom (this will be in a separate blog post)
Load your image into VrPanoramaView
I want to implement gallery photo picker similar to what Messenger is using.
That means I dont want to open fullscreen gallery but only small window at the bottom of the screen with photos in grid. Is this possible with native support or it is completely custom design?
I'm using standard intent to access gallery. But someone consider standard gallery access which behaves and looks like in Messenger app.
Gallery Intent:
private fun openGallery() {
val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
a.startActivityForResult(intent, REQUEST_GALLERY_CODE)
}
You can do it yourself with a bottomsheet dialog or you can just use this library
https://github.com/kroegerama/bottomsheet-imagepicker
FishBun is a flexible library to create a gallery in your application.
It also supports various visual styles and allows fine-tuning for details.
Just implement this in your build.gradle file
repositories {
jcenter()
}
dependencies {
// Under the Android Plugin 3.0.0.
compile 'com.sangcomz:FishBun:0.10.0'
compile 'com.squareup.picasso:picasso:2.71828'
or
compile 'com.github.bumptech.glide:glide:4.9.0'
// Android plugin 3.0.0 or higher.
implementation 'com.sangcomz:FishBun:0.11.0'
implementation 'com.squareup.picasso:picasso:2.71828'
or
implementation 'com.github.bumptech.glide:glide:4.9.0'
}
and to allow the following permissions in your Manifest:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
To create a basic gallery use the following code:
FishBun.with(WithActivityActivity.this)
.setImageAdapter(new GlideAdapter())
.startAlbum();
I would like to display the URL preview entered by the user like skype app in . For example if i am entering a youtube url in the skype app to other person , it is automatically displaying the thumbnail preview of that URL entered by the user.
https://www.youtube.com/watch?v=QUgRDYehv0M
When i have entered above url means.. Skype automatically showing the thumbnail preview of that link like below:
Like skype i would like to do in android. Whenever if user enters any url means.. i need to show the preview of an url..
https://play.google.com/store/apps/details?id=com.leocardz.link.preview&feature=search_result
Refered above app.. anyother help or guidance will be helpful.
You can import the library using Gradle :
Simply add the repository to your build.gradle file:
repositories {
jcenter()
maven { url 'https://github.com/leonardocardoso/mvn-repo/raw/master/maven-deploy' }
}
And you can use the artifacts like this:
dependencies {
compile 'org.jsoup:jsoup:1.8.3' // required
compile 'com.leocardz:link-preview:1.2.1#aar'
}
You can refer this link for more details.
I want to add a default profile picture for my logged in user in my Android application. The way android marshmallow and above android version provides default alphabetical contact picture in contacts. There is a similar application "Micopi Pico". I want to use such functionality in my Android application to display the alphabetical profile picture as user's default profile picture. Is there any library or API or any method to do so? please help me.
There are many libraries to do that, here is an example, a library called Text Drawable (Click here to know more)
Import with Gradle:
repositories{
maven {
url 'http://dl.bintray.com/amulyakhare/maven'
}
}
dependencies {
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
}
Usage :
TextDrawable drawable = TextDrawable.builder()
.buildRect("A", Color.RED);
ImageView image = (ImageView) findViewById(R.id.image_view);
image.setImageDrawable(drawable);
You can go through the documentation to know more about the usage.
You should always try searching for a solution to your problem before asking a question in stack overflow.
I don't think it's duplicating 'cause all the answers I've found were made several years ago. So, I load bitmap from URL and then do it this way:
currentView.setBackground(new BitmapDrawable(result));
...where "result" is Bitmap.
But "BitmapDrawable" is deprecated and it doesn't work from API 22 or 21.
Are there some other way of converting Bitmap to Drawable or loading drawable from URL instead of Bitmap?
As the documentation tells you - don't use the deprecated
new BitmapDrawable(result)
Instead use the API 18 version
new BitmapDrawable(getActivity().getResources(), result)
Assuming you're supporting API 18+, otherwise you need to handle both version depending on the runtime API.
Use Glide to load image from URL, Glide is a fast and efficient open source media management and image loading framework for Android that wraps media decoding, memory and disk caching, and resource pooling into a simple and easy to use interface.
Glide takes care of making scrolling any list of images as smooth as possible and also receive, resize and display remote image.
For more information refer here
Add below dependencies in build.gradle:
dependencies {
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.android.support:support-v4:19.1.0'
}
Eg project https://github.com/chrisbanes/cheesesquare
Eg usage:
#Override
public void onCreate(Bundle savedInstanceState) {
...
ImageView imageView = (ImageView) findViewById(R.id.my_image_view);
Glide.with(this).load("http://goo.gl/gEgYUd").into(imageView);
}
In the load method just pass the URL of the image and in into just pass the view, in you case currentview.
For your scenario:
Glide.with(this).load("http://goo.gl/gEgYUd").into(currentView);