Translate

Sunday, February 25, 2018

Can we use PHP in Android Application..is it possible to develop complete Android App with PHP ?


PHP is a server side scripting language. Php is for fetching data from the datastore, perform bussiness logics, then dump the necessary html pages on the browser for rendering. Php does not have ui toolkits. It relies on html. There are html5 and js frameworks like cordova, angular, react etc you can use for that.

The PHP interpreter isn't available on a mobile device, which is why cannot package PHP files into a Android app and expect it to work.
You could however write your backend in PHP and use XMLHTTP calls (in JavaScript) to retrieve data and present it to the user.

One more thing There's no webviev anymore in Android 8.1 new version release that they deleted it . Without Webview we can make progressive web apps and we can still use string in which you will enter iframe . You can make iframe be responsive to all devices and you kinda have your android app.

To develop Android Mobile App through PHP most time three layers required:
  1. Android App Layer - where developer has to develop App which will run on Android platform.
  2. Web Services - this is back-end service layer, It can be develop in PHP, Java, .NET etc. PHP is most freeware language, and the cost of development also less than others.
  3. Database : Last layer where data is saved. Mobile Android App interact with Web services and Web services interact with Database.

Thursday, February 15, 2018

code to get all the sim and carrier properties in Android oreo(v26)

package simcarrier.example.com.carrierproperties;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    TelephonyManager telManager ;
    String networkOperator;
    String propertiesStr = "";
    TextView carrierPropertiesTxtView;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        carrierPropertiesTxtView = findViewById(R.id.carrierProperties);

        telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        networkOperator = telManager.getNetworkOperator();

        if (checkSelfPermission(android.Manifest.permission.READ_PHONE_STATE)
                == PackageManager.PERMISSION_GRANTED ||
                checkSelfPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
                        == PackageManager.PERMISSION_GRANTED ) {
            Log.v("TAG","Permission is granted");

            getCarrierProp();

        } else {
            Log.v("TAG","Permission is revoked");
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE , Manifest.permission.ACCESS_NETWORK_STATE}, 1);
        }


    }


    @Override    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if(grantResults[0]== PackageManager.PERMISSION_GRANTED){
            Log.v("TAG","Permission: "+permissions[0]+ "was "+grantResults[0]);
            getCarrierProp();
        }
    }


    private void getCarrierProp(){
        try{
            if (!TextUtils.isEmpty(networkOperator)) {
                int mcc = Integer.parseInt(networkOperator.substring(0, 3));
                int mnc = Integer.parseInt(networkOperator.substring(3));

                propertiesStr = propertiesStr+ " MCC="+mcc
                        +"\n MNC="+mnc
                        +"\n GID1         :      " + telManager.getGroupIdLevel1()
                        +"\n Device       :      " + Build.DEVICE                        +"\n MANUFACTURER :      " + Build.MANUFACTURER                        +"\n MODEL        :      " + Build.MODEL                        +"\n Network operator:   " + telManager.getNetworkOperator()
                        +"\n Network operatorName: " + telManager.getNetworkOperatorName()
                        +"\n Network type:      " + telManager.getNetworkType()
                        +"\n Sim Operator:      " + telManager.getSimOperator()
                        +"\n Sim Operator name: " + telManager.getSimOperatorName()
                        +"\n Sim State   :      " + telManager.getSimState()
                        +"\n Sim SerialNo:      " + telManager.getSimSerialNumber()
                        +"\n PhoneNumber :      " + telManager.getLine1Number();

                carrierPropertiesTxtView.setText(propertiesStr);
            }
        }catch(SecurityException e){
            // SIM methods can cause Exceptions on some devices            e.printStackTrace();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}







Could not identify launch activity: Default activity not found : Error while Launching activity

Problem : I got this Error , When I tried to create an application without any Activity . Basically like to develop an Android Headless appl...