Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. How Can Initialize MediaSettings In Android Activity

how can initialize MediaSettings in android activity

By Akash , 3 April, 2024
Forums
Gurux DLMS for Android

package gurux.dlms.android.ui.media;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider;

import gurux.dlms.android.R;
import gurux.dlms.android.databinding.FragmentMediaBinding;

public class MediaFragment extends Fragment {

private FragmentMediaBinding binding;

public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
MediaViewModel mediaViewModel =
new ViewModelProvider(requireActivity()).get(MediaViewModel.class);

binding = FragmentMediaBinding.inflate(inflater, container, false);
View view = binding.getRoot();
Fragment childFragment = mediaViewModel.getDevice().getMedia().properties();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.replace(R.id.media_fragment_container, childFragment).commit();
return view;
}

@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}
}

Profile picture for user Kurumi

Kurumi

2 years 3 months ago

Hi, You need to get the…

Hi,

You need to get the media and then you can change the settings.
Something like this for serial port:

GXSerial serial = (GXSerial) mediaViewModel.getDevice().getMedia();
serial.getBaudRate();

BR,
Mikko

Akash

2 years 3 months ago

Thank you ....

Thank you ....

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701
  • Thu, 07/23/2026 - 16:19
    gurux.dlms.java 4.0.96
  • Thu, 07/09/2026 - 14:34
    Gurux.DLMS.Python 1.0.201
  • Fri, 06/26/2026 - 16:32
    Gurux.Service 3.0.2606.2601
  • Wed, 06/24/2026 - 08:36
    Gurux.DLMS.Python 1.0.200

New forum topics

  • Service not known error on gprs communication
  • Help Needed: Interfacing Saral 100 Energy Meter with Microcontroller via RS232
  • Connecting Meter to Agent via serial
  • Reading block profile with Compact array
  • DLMS server - serving multiple similar datasets gathered from multiple meters across distinct logical addresses
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin