Android Open Source - welcome-android Native App Info Fragment






From Project

Back to project page welcome-android.

License

The source code is released under:

Copyright (c) 2014 FeedHenry Ltd, All Rights Reserved Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software")...

If you think the Android project welcome-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.feedhenry.android.fragments;
//  w  ww  .  j  a v  a2s .co m
import org.json.fh.JSONObject;

import android.app.Fragment;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.feedhenry.android.R;
import com.feedhenry.android.server.FHAgent;
import com.feedhenry.android.utilities.MyToast;
import com.feedhenry.sdk.FHActCallback;
import com.feedhenry.sdk.FHResponse;

public class NativeAppInfoFragment extends Fragment {
  
  private View rootView;
  private String manufacturer, model, product, serial, cpu, host, release, codename;
  private String fhVarAppName, fhVarAppDomain, fhVarAppEnv, fhVarAppPort;
  private int sdkNum;

  @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_app_info, container, false);
        getVars();
        initUI();
        getCloudInfo();
        return rootView;
    }

  
  private void getCloudInfo() {
    // Use FH Agent to call the FH Vars
        FHAgent fhAgent = new FHAgent();
        fhAgent.getFHVars(new FHActCallback() {
          @Override
          public void success(FHResponse fhResponse) {
            parseInfo(fhResponse.getJson());
            Log.i("FEEDHENRY", "FH Vars Call Success! "
                + fhResponse.getJson());
          }
          @Override
          public void fail(FHResponse fhResponse) {
            
            MyToast.showToast("Could not reach cloud");
            Log.i("FEEDHENRY", fhResponse.getRawResponse());
            Log.i("FEEDHENRY", "FH Vars Call Failed!");
          }
        });
  }
  
  
  private void parseInfo(JSONObject json) {
    
    TextView tv8 = (TextView) rootView.findViewById(R.id.textView8);
        TextView tv9 = (TextView) rootView.findViewById(R.id.textView9);
        TextView tv10 = (TextView) rootView.findViewById(R.id.textView10);
        TextView tv11 = (TextView) rootView.findViewById(R.id.textView11);
        
        // This assumes that every cloud app will have these Environment Vars
        tv8.setText(json.getString("appName"));
        tv9.setText(json.getString("domain"));
        tv10.setText(json.getString("env"));
    tv11.setText(json.getString("port"));
  }


  private void getVars() {
    manufacturer = Build.MANUFACTURER;
        model = Build.MODEL;
        product = Build.PRODUCT;
        serial = Build.SERIAL;
        cpu = Build.CPU_ABI;
        host = Build.HOST;
        release = Build.VERSION.RELEASE;  
        sdkNum = Build.VERSION.SDK_INT;        
        codename = "";
        if(Build.VERSION_CODES.ICE_CREAM_SANDWICH == sdkNum || Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 == sdkNum) {
          codename = "Ice Cream Sandwich";
        } else if(Build.VERSION_CODES.JELLY_BEAN == sdkNum || Build.VERSION_CODES.JELLY_BEAN_MR1 == sdkNum || Build.VERSION_CODES.JELLY_BEAN_MR2 == sdkNum) {
          codename = "Jelly Bean";
        } else if(sdkNum > 18) {
          codename = "Kit Kat";
        }
  }

  
  private void initUI() {
    TextView tv1 = (TextView) rootView.findViewById(R.id.textView1);
        TextView tv2 = (TextView) rootView.findViewById(R.id.textView2);
        TextView tv3 = (TextView) rootView.findViewById(R.id.textView3);
        TextView tv4 = (TextView) rootView.findViewById(R.id.textView4);
        TextView tv5 = (TextView) rootView.findViewById(R.id.textView5);
        TextView tv6 = (TextView) rootView.findViewById(R.id.textView6);
        TextView tv7 = (TextView) rootView.findViewById(R.id.textView7);
        
        tv1.setText(manufacturer);
        tv2.setText(model);
        tv3.setText(product);
        tv4.setText(serial);
        tv5.setText(cpu);
        tv6.setText(host);
        tv7.setText("Android Version: " + release + "  " + codename);
  }
}




Java Source Code List

com.feedhenry.android.MainActivity.java
com.feedhenry.android.MyApplication.java
com.feedhenry.android.drawer.adapter.NavDrawerListAdapter.java
com.feedhenry.android.drawer.model.NavDrawerItem.java
com.feedhenry.android.fragments.CallCloudFragment.java
com.feedhenry.android.fragments.CloudIntegrationsFragment.java
com.feedhenry.android.fragments.DataBrowserFragment.java
com.feedhenry.android.fragments.HomeFragment.java
com.feedhenry.android.fragments.LocationFragment.java
com.feedhenry.android.fragments.NativeAppInfoFragment.java
com.feedhenry.android.fragments.PushNotificationsFragment.java
com.feedhenry.android.fragments.StatsFragment.java
com.feedhenry.android.server.FHAgent.java
com.feedhenry.android.utilities.KeyboardToggle.java
com.feedhenry.android.utilities.MyLocation.java
com.feedhenry.android.utilities.MyToast.java