Get Started with Galaxy Store Developer API
-
Similar Topics
-
By Samsung Newsroom
Samsung Galaxy Fold devices have taken the mobile industry by storm, offering users a revolutionary way to interact with their applications. One of their key features is the rear display mode that enables users to continue their tasks seamlessly on the cover display while the main display remains turned off. Jetpack WindowManager has introduced APIs to enable this mode programmatically, and starting from One UI 6.0, developers can now utilize these APIs to integrate rear display mode into their applications, enhancing usability and maximizing the potential of foldable devices.
In this blog post, we dive deeper into implementing Jetpack WindowManager's rear display mode in a camera application. By leveraging this mode, users can take selfies with superior image quality using the rear camera instead of the front camera. Join us as we explore the exciting possibilities of foldable technology and uncover how to optimize your applications for the Samsung Galaxy Fold.
You can download the sample camera application here.
CameraXApp.zip (623.3 KB) Sep 26, 2024 Step 1: Add the WindowManager library into the project
WindowManager, a Jetpack library introduced by Google, supports rear display mode starting from version 1.2.0-beta03. To add the WindowManager library, go to Gradle Scripts > build.gradle (Module: app) and enter the following to the dependencies block:
implementation "androidx.window:window:1.3.0" Step 2: Implement the WindowAreaSessionCallback interface in MainActivity.kt
The WindowAreaSessionCallback interface updates an Activity about when the WindowAreaSession is started and ended. Using the onSessionStarted method, this interface provides the current WindowAreaSession as soon as a new window session is started.
class MainActivity : AppCompatActivity() , WindowAreaSessionCallback { … override fun onSessionEnded(t: Throwable?) { if(t != null) { println("Something was broken: ${t.message}") } } override fun onSessionStarted(session: WindowAreaSession) { } } Step 3: Declare variables
The WindowAreaController provides information about the moving windows between the cover display and the main display of the Galaxy Fold device.
The WindowAreaSession interface provides an active window session in the onSessionStarted method.
WindowAreaInfo represents the current state of a window area. It provides a token which is used later to activate rear display mode.
WindowAreaCapability.Status represents the availability and capability status of the window area defined by the WindowAreaInfo object. We utilize this status to change the UI of our application. The status of the Galaxy Fold device can be one of the following:
WINDOW_AREA_STATUS_ACTIVE: if the cover display is currently active.
WINDOW_AREA_STATUS_AVAILABLE: if the cover display is available to be enabled.
WINDOW_AREA_STATUS_UNAVAILABLE: if the cover display is currently not available to be enabled.
WINDOW_AREA_STATUS_UNSUPPORTED: if the Galaxy Fold device is running on Android 13 or lower.
private lateinit var windowAreaController: WindowAreaController private var windowAreaSession: WindowAreaSession? = null private var windowAreaInfo: WindowAreaInfo? = null private var capabilityStatus: WindowAreaCapability.Status = WindowAreaCapability.Status.WINDOW_AREA_STATUS_UNSUPPORTED private val operation = WindowAreaCapability.Operation.OPERATION_TRANSFER_ACTIVITY_TO_AREA Step 4: Create an instance of WindowAreaController in the onCreate method
windowAreaController = WindowAreaController.getOrCreate() Step 5: Set up a flow to get information from WindowAreaController
In the onCreate() method, add a lifecycle-aware coroutine to query the list of available WindowAreaInfo objects and their status. The coroutine executes each time the lifecycle starts.
lifecycleScope.launch(Dispatchers.Main) { lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) { windowAreaController.windowAreaInfos .map { info -> info.firstOrNull { it.type == WindowAreaInfo.Type.TYPE_REAR_FACING } } .onEach { info -> windowAreaInfo = info } .map { it?.getCapability(operation)?.status ?: WindowAreaCapability.Status.WINDOW_AREA_STATUS_UNSUPPORTED } .distinctUntilChanged() .collect { capabilityStatus = it updateUI() } } } Step 6: Update the UI according to the device's WindowAreaCapability.Status
private fun updateUI() { if(windowAreaSession != null) { viewBinding.switchScreenButton.isEnabled = true } else { when(capabilityStatus) { WindowAreaCapability.Status.WINDOW_AREA_STATUS_UNSUPPORTED -> { viewBinding.switchScreenButton.isEnabled = false Toast.makeText(baseContext, "RearDisplay is not supported on this device", Toast.LENGTH_SHORT).show() } WindowAreaCapability.Status.WINDOW_AREA_STATUS_UNAVAILABLE -> { viewBinding.switchScreenButton.isEnabled = false Toast.makeText(baseContext, "RearDisplay is not currently available", Toast.LENGTH_SHORT).show() } WindowAreaCapability.Status.WINDOW_AREA_STATUS_AVAILABLE -> { viewBinding.switchScreenButton.isEnabled = true } WindowAreaCapability.Status.WINDOW_AREA_STATUS_ACTIVE -> { viewBinding.switchScreenButton.isEnabled = true Toast.makeText(baseContext, "RearDisplay is currently active", Toast.LENGTH_SHORT).show() } else -> { viewBinding.switchScreenButton.isEnabled = false Toast.makeText(baseContext, "RearDisplay status is unknown", Toast.LENGTH_SHORT).show() } } } } Step 7: Toggle to rear display mode with WindowAreaController
Close the session if it is already active, otherwise start a transfer session to move the MainActivity to the window area identified by the token.
While activating rear display mode, the system creates a dialog to request the user’s permission to allow the application to switch screens. This dialog is not customizable.
private fun toggleRearDisplayMode() { if(capabilityStatus == WindowAreaCapability.Status.WINDOW_AREA_STATUS_ACTIVE) { if(windowAreaSession == null) { windowAreaSession = windowAreaInfo?.getActiveSession( operation ) } windowAreaSession?.close() } else { windowAreaInfo?.token?.let { token -> windowAreaController.transferActivityToWindowArea( token = token, activity = this, executor = displayExecutor, windowAreaSessionCallback = this ) } } } Step 8: Start the camera preview
Call startCamera() when onSessionStarted is triggered by the WindowAreaSessionCallback interface.
override fun onSessionStarted(session: WindowAreaSession) { startCamera() } Step 9: Add a button and set a listener to it for activating rear display mode
<Button android:id="@+id/switch_screen_button" android:layout_width="110dp" android:layout_height="110dp" android:layout_marginStart="50dp" android:elevation="2dp" android:text="@string/switch_screen" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@+id/horizontal_baseline" app:layout_constraintStart_toEndOf="@id/vertical_centerline" /> viewBinding.switchScreenButton.setOnClickListener{ updateUI() toggleRearDisplayMode() } Incorporating rear display mode into your application can significantly enhance user experience by providing more intuitive control and greater flexibility. By following the outlined steps, you can create a more dynamic and user-friendly interface. As technology continues to evolve, staying ahead with features like rear display mode can set your application apart and offer users a seamless, professional-quality experience. To learn more about developing applications for Galaxy Foldable devices, visit: developer.samsung.com/galaxy-z.
View the full blog at its source
-
By Samsung Newsroom
A sensor's maximum and minimum values are crucial for calibration, data interpretation, threshold setting, user interface, error handling, sensor selection, and performance optimization.
Understanding the expected range of values helps identify and handle sensor errors or anomalies, and selecting the right sensor for the intended use case is essential. Efficient use of sensor data, especially in resource-constrained environments like mobile devices, can optimize data processing algorithms.
The maximum and minimum values of sensors play a crucial role in the accurate and efficient functioning of sensor-based applications across various domains. In this tutorial, a wearable application is developed to collect the maximum and minimum ranges of sensors from a Galaxy Watch running Wear OS powered by Samsung. This tutorial shows how to retrieve all sensor ranges together, as well as from one specific sensor separately.
Environment
Android Studio IDE is used for developing the Wear OS application. In this tutorial, Java is used, but Kotlin can also be used.
Let’s get started
The SensorManager library is used here to collect sensor data from a Galaxy Watch running Wear OS powered by Samsung.
Retrieve the maximum range of a sensor
To get access and retrieve the maximum ranges from the sensor:
In Android Studio, create a wearable application project by selecting New Project > Wear OS > Blank Activity > Finish. To access the sensor, add the body sensor in the application’s “manifests” file.
<uses-permission android:name="android.permission.BODY_SENSORS" /> To run the application on devices with Android version 6 (API level 23) or later, you need runtime permission from the user to use the BODY_SENSORS APIs.
Add the following code snippet to the onCreate() method before calling any sensor operations:
if (checkSelfPermission(Manifest.permission.BODY_SENSORS) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{Manifest.permission.BODY_SENSORS}, 1); } else { Log.d("TAG___", "ALREADY GRANTED"); } After this code executes, a pop-up window appears and requests permission from the user. The sensor APIs return values only if the user grants permission. The application asks for permission only the first time it is run. Once the user grants permission, the application can access the sensors.
Figure 1: Permission screen
More details about runtime permissions can be found here.
Create an instance of the SensorManager library before using it in the code.
private SensorManager sensorManager; sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); To retrieve the maximum range of all sensors, create a sensor list using API Sensor.TYPE_ALL.
List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ALL); ArrayList<String> arrayList = new ArrayList<String>(); for (Sensor sensor : sensors) { if (sensor != null) { arrayList.add(sensor.getName()); arrayList.add(sensor.getMaximumRange() + ""); arrayList.add(sensor.getResolution() + ""); } } arrayList.forEach((n) -> System.*out*.println(n)); The above code shows the sensor name, maximum range, and resolution. You can get all the available data from the sensors, such as type, vendor, version, resolution, maximum range, and power consumption, by applying this same approach.
Remember, sensor information may vary from device to device.
Additionally, not every sensor that appears in the logcat view is accessible. Third-party applications are still not allowed to access Samsung's private sensors using the Android SensorManager. You get a “null” value if you try to access the private sensors.
Moreover, there are no plans to make these sensors available to the public in the near future.
You can check my blog Check Which Sensor You Can Use in Galaxy Watch Running Wear OS Powered by Samsung to find out which sensors are accessible on your Galaxy Watch and which are not.
Retrieve the minimum range of a sensor
The minimum range is the complement of maximum range.
If the maximum range is x, then the minimum range can be calculated like this: x*(-1) = -x.
If a specific sensor value should always be absolute, then the minimum range is zero (0).
There is no direct API available to retrieve the minimum range of sensors from Galaxy Watch.
Get a specific sensor value
To get specific sensor values from a Galaxy Watch, you can filter the sensor list or use the getDefaultSensor() method. Here is an example that demonstrates how to do this. Add the necessary permission in the “manifests” file for the accelerometer sensor:
<uses-feature android:name="android.hardware.sensor.accelerometer" /> Use the following code in your Activity or Fragment to retrieve the accelerometer data:
sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); if (sensor != null) { textView_maxV.setText(textView_maxV.getText() + "" + sensor.getMaximumRange() + ""); textView_resolution.setText(textView_resolution.getText() + "" + sensor.getResolution() + ""); } Ensure you have added the TextView element to your XML file. Output of the above code:
Figure 2: Maximum range and resolution of the accelerometer
Remember, sensor ranges may vary from device to device. You may get different values for different Galaxy Watch models.
Download the example from this blog:
SensorMinxMax (313.2KB) Sep 10, 2024 Summary
This article demonstrates how you can retrieve the maximum and minimum ranges of sensors from your Galaxy Watch running Wear OS powered by Samsung. You can also use the above approaches to get other necessary available information from the watch that can be used for the precise and effective operation of sensor-based applications in a variety of fields.
If you have any questions about or need help with the information in this article, you can reach out to us on the Samsung Developers Forum or contact us through Developer Support.
View the full blog at its source
-
By Samsung Newsroom
Samsung Art Store is a subscription service that enables owners of The Frame to continuously transform any space with over 2,500 pieces of digital art, including works from the most renowned artists, museums and industry tastemakers. It brings the experience of an art gallery directly into the home in a 4K frame that is a TV when on, and an art display when it’s off.
Samsung Art Store is designed to effortlessly accentuate home décor, serving as a premium versatile art display. Users can transform their private spaces to reflect changing styles, displaying from renowned classic masterpieces, remarkable contemporary artworks to professionally curated collections selected by the Samsung Art Store curator to match any aesthetic.
See how Samsung Art Store gives the ease and flexibility to enhance any space for every occasion in the infographic below.
View the full article
-
By Samsung Newsroom
There are no clear answers when appreciating art. Each piece will evoke distinct emotions and elicit different reactions. However, context on the artist or artwork’s inspiration can heighten understanding — so people can admire art on a whole new level.
▲ Since 2021, Samsung Newsroom interviewed 35 artists and organizations that partnered with Samsung Art Store
Samsung’s art subscription service has brought once distant and inaccessible art into the comfort and intimacy of the home via the company’s lifestyle TV, The Frame. Samsung Art Store has been acclaimed for creating a new paradigm in art consumption by overcoming the physical constraints of traditional art exhibitions and transforming living spaces into galleries.
Subscribers have access to over 2,500 works of art presented in 4K resolution, ranging from photographs and illustrations to masterpieces from prestigious galleries and museums.
Beginning in 2021, Samsung Newsroom illuminated the stories behind these works of art through interviews with artists and representatives from partnering art organizations. This initiative aimed to enhance the art-viewing experience by conveying each artist’s methods and motivations. Samsung Newsroom revisited the past three years with Samsung Art Store, a digital curator enriching daily life with art.
35 Samsung Art Store Partners and 35 Distinct Perspectives
Samsung Newsroom interviewed a total of 35 Samsung Art Store artists. From the 2,500 pieces of art available, collections were created based on seasons or collaboration milestones. Artists and partnership representatives were then selected for interviews with these themed curations in mind.
The interviews offered Samsung Art Store subscribers a deeper understanding of the art by providing otherwise rarely accessible details about each artist’s life and values. Saya Woolfalk is one artist whose personal story shapes her creativity.
▲ (From left) Saya Woolfalk and “Sassafras” (2021)
Woolfalk utilizes various mediums including textiles and a combination of traditional print methods and digital print processes. In her interview, she discussed how her unique upbringing significantly shaped her creative world. Born and raised in New York, Woolfalk shared stories of spending summers with her maternal grandmother in Gifu, Japan. Some of her textile collages were inspired by these experiences.
▲ (From left) Serge Hamad and “Beach #4” (2011)
Serge Hamad, the most recent interviewee, is another artist whose upbringing is vividly reflected in his work. Inspired by the Mediterranean coast where he was born and raised, the “Relax” series marked his debut in fine art photography. In his interview, Hamad discussed how his multicultural North African and Western background influences his artistic vision.
▲ (From left) Natasha Durley and “As Mad as a March Hare” (2021)
The interviews have also introduced lesser-known artists. Natasha Durley creates vibrant, colorful illustrations inspired by her passion for animals and nature. She even follows biologists on social media for inspiration. In her interview, she revealed that she used to work at a call center before pursuing her dream of becoming an artist.
Durley shared that a portion of the proceeds from the collaboration benefits a biodiversity creation non-profit — highlighting Samsung Art Store’s positive impact on the broader ecosystem.
A Digital Curator Connecting Artists and Audiences Around the World
Samsung Art Store is building an extensive global portfolio of masterpieces that includes artists from diverse cultural backgrounds and artwork spanning various styles. By interviewing partnership representatives from esteemed museums and galleries worldwide, Samsung Newsroom offered Samsung Art Store subscribers behind-the-scenes stories of renowned pieces and tips for deeper appreciation.
▲ “Circus Sideshow (Parade de Cirque)” (1878-88) by Georges Seurat from The Metropolitan Museum of Art
Viewing historical paintings in digital forms can offer fresh perspectives. Stephen Mannello, Head of Retail and Licensing at the Metropolitan Museum of Art (The Met), recommended Georges Seurat’s “Circus Sideshow” as a particularly engaging piece to display on The Frame. Other beloved works from The Met’s collection include pieces by Vincent van Gogh and Paul Cézanne, conveying the timeless impact of art across different eras and spaces.
▲ “Sunflowers” (1889) by Vincent van Gogh from the Van Gogh Museum
Modern art is characterized by artists’ innovative expressions and interpretations that redefine the art world to encompass a spectrum of art styles spanning different eras and fields. Samsung Newsroom showcased some of the best modern and contemporary artists transcending both time and form — from Vincent van Gogh, who heralded the beginning of modern art, to Aerosyn-Lex Mestrovic, who is recognized across various mediums including fashion, film and live art performances.
▲ “VERSALIS DRIP MMXXII” (2022) by Aerosyn-Lex Mestrovic
Aerosyn-Lex Mestrovic is a prominent multidisciplinary artist renowned for his striking and emotive works, with works exhibited at the Museum of Modern Art (MoMA) and the White House. In his interview last year, he explained his signature ethereal ink painting technique and his representative work, “VERSALIS DRIP MMXXII.” In addition, Mestrovic recommended his favorite pieces available on Samsung Art Store for those who are unfamiliar with modern art.
To broaden the artistic horizons of Samsung Art Store subscribers, Samsung Newsroom introduced a diverse range of photographic artworks — from black-and-white photos to unconventionally angled aerial shots — along with stories from the artists about how they were created.
▲ “Vortex” (2009) by Wolf Ademeit
Wolf Ademeit, a photographer known for his black-and-white wildlife photographs, highlighted the significant role that luck plays in animal photography during his interview. To capture “Vortex,” he repeatedly visited the zoo for months until the zebra posed perfectly for the shot. Such anecdotes allowed Samsung Art Store subscribers to gain a deeper appreciation for the value and effort embedded in Ademeit’s work.
▲ “Red Dunes” (2021) by Palani Mohan
Palani Mohan offered a glimpse into the impact of the pandemic during his interview. Spending half of the year on the road capturing various landscapes, he gained a new perspective of Hong Kong and the local environment. Through his representative work “Red Dunes,” Mohan displayed his passion for vibrant colors and photography.
▲ “Playa Shoreline” (2015) by Tommy Clarke
Tommy Clarke, a world-renowned aerial photographer, underscored the significance of angles in photography during his interview — showcasing fresh perspectives and compositions captured from a helicopter.
Artists and representatives praised Samsung Art Store’s strength in overcoming physical constraints. The platform allows subscribers to easily access art from distant continents that might otherwise remain inaccessible while helping artists expand their reach and explore new opportunities.
▲ “She Snap” by Manzi Leon
The interview with African art organization Artlife Matters introduced previously unfamiliar African art to Samsung Art Store subscribers. Notably, “She Snap” by Manzi Leon expressed the thoughts and feelings of women within his community — sparking imaginations and deepening engagement with the piece.
▲ “Axon” (2018) by Logan Hicks
Logan Hicks, Samsung Art Store’s first contemporary artist, gained significant attention in his interview. Residing in New York City, he uses multiple layers of stencils to blend urban aesthetics with extreme precision and detail. His work resonates with those nostalgic for New York or wishing to experience the city’s streets for themselves. The collaboration between Hicks and Samsung Art Store is an unprecedented example of overcoming the physical limitations of art appreciation, bringing street art into the homes of subscribers.
Expanding Art’s Reach With Samsung Art Store
Art continues to transcend physical boundaries to reach a wider global audience — and Samsung Art Store is expanding public access to art by providing a new platform for exhibiting pieces. By using technology to lower the barriers to art appreciation, Samsung will continue to inspire Samsung Art Store subscribers and art enthusiasts everywhere through collaborations and stories.
Explore past interviews in the link below. (Note: Some partnerships may have expired. Please check on Samsung Art Store to see latest list of offerings.)
View the full article
-
-
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.