Skip to main content
Home
for DLMS smart meters

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

1 year 7 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

1 year 7 months ago

Thank you ....

Thank you ....

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Thu, 11/13/2025 - 15:23
    Gurux.DLMS.Python 1.0.192
  • Thu, 11/13/2025 - 14:55
    gurux.dlms.java 4.0.84
  • Wed, 10/29/2025 - 08:51
    gurux.dlms.c 9.0.2510.2901
  • Thu, 10/16/2025 - 09:59
    gurux.dlms.java 4.0.83
  • Wed, 10/08/2025 - 10:21
    gurux.dlms.c 9.0.2510.0801

New forum topics

  • how to get attribute 2 type for GXDLMSData object in python
  • Guidance on using the source codes
  • How to get/convert user readable format data from readRowsByRange
  • Insufficient memory to continue the execution of the program.
  • The client instance code failed to connect to the electricity meter for authentication
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin