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 8 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, 12/11/2025 - 13:22
    Gurux.DLMS.Python 1.0.194
  • Thu, 12/11/2025 - 11:01
    gurux.dlms.java 4.0.86
  • Wed, 12/10/2025 - 08:45
    gurux.dlms.java 4.0.85
  • Tue, 12/02/2025 - 10:21
    gurux.dlms.c 9.0.2512.0201
  • Mon, 12/01/2025 - 13:55
    Gurux.DLMS.Python 1.0.193

New forum topics

  • Gurux.Net
  • GXTIME Conversion Issue
  • DLMS Meter Gurux DLMS Director Properties
  • Using MAX3232 + FT232RL to Energy meter with GXDLMS Director
  • Incomplete Firmware Upgrade Process
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin