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();
Related
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.
This question already has answers here:
How to display image from URL on Android
(10 answers)
Closed 2 years ago.
how can I get image asset(from online or somewhere else) so that i can insert an image in my android app using android studio?
Using Image library is easy way. (like Glide, Picasso, etc.)
for example. (using Glide)
String imageUrl = "https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory&fname=https://k.kakaocdn.net/dn/EShJF/btquPLT192D/SRxSvXqcWjHRTju3kHcOQK/img.png";
Glide.with(this).load(imageUrl).into(ivImage);
it make image from url.
Plus. how you can use Glide
Add the dependencies in build.gradle(app)
dependencies {
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
and use it.
more info is here
The best way to do would be to use third party image libraries like Glide, Picasso, etc.
Here is how you can easily do it using Glide
Add the dependencies in build.gradle(app)
dependencies {
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
Using Glide to fetch the images
ImageView targetImageView = (ImageView) findViewById(R.id.imageView);
String internetUrl = "http://i.imgur.com/DvpvklR.png";
Glide
.with(context)
.load(internetUrl)
.into(targetImageView);
You can refer to this tutorial for more
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 have an app where i am adding shortcut. I want to add shortcut icon image from URL path(images are stored on server and can be change) instead of using Drawable but i don't know how to do that. I tried to find a lot on this community. Any help?
If the term used "shortcut icon" is a view or its descendants such as ImageView, then you can set the image, your application receive from the server by doing this :
add dependency to your app.gradle file :
compile 'com.github.bumptech.glide:glide:3.7.0'
and in the activity you can use this method to set the image to the imageview your app receive from the server :
ImageView imageView = (ImageView) findViewById(R.id.image_view);
Glide.with(imageview.getContext()).load("https://url").error(R.drawable.not_found).centerCrop().into(imageview);
What you could do is first download that icon and store locally and then take that file path and use
ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(this, UUID.randomUUID().toString())
.setIntent(intent) // !!! intent's action must be set on oreo
.setShortLabel(lable)
.setIcon(IconCompat.createWithAdaptiveBitmapContentUri(filePath)).build();
ShortcutManagerCompat.requestPinShortcut(this, shortcutInfo, null);
add this in your build.gradle
compile 'com.squareup.picasso:picasso:2.5.2'
now you can load the image using following code
Picaso.with(this).load(urlHere).into(imageView);
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.