Develop an Android Auto custom app

后端 未结 3 1639
情书的邮戳
情书的邮戳 2021-02-03 14:38

I\'m an Android developer and I\'m trying to develop a custom Android Auto app, that does a simple mirroring of the phone screen. I know that currently the API are only availabl

3条回答
  •  孤城傲影
    2021-02-03 15:06

    The Main Activity File

    The main activity code is a Java file MainActivity.java. This is the actual application file which ultimately gets converted to a Dalvik executable and runs your application. Following is the default code generated by the application wizard for Hello World! application −

    package com.example.helloworld;
    
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    
    public class MainActivity extends AppCompatActivity {
       @Override
       protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
       }
    }
    

    The Manifest File

    Whatever component you develop as a part of your application, you must declare all its components in a manifest.xml which resides at the root of the application project directory. This file works as an interface between Android OS and your application, so if you do not declare your component in this file, then it will not be considered by the OS. For example, a default manifest file will look like as following file −

    
    
    
       
    
          
             
                
                
             
          
       
    
    

    The Strings File

    The strings.xml file is located in the res/values folder and it contains all the text that your application uses. For example, the names of buttons, labels, default text, and similar types of strings go into this file. This file is responsible for their textual content. For example, a default strings file will look like as following file −

    
       HelloWorld
       Hello world!
       Settings
       MainActivity
    
    

    The Layout File

    The activity_main.xml is a layout file available in res/layout directory, that is referenced by your application when building its interface. You will modify this file very frequently to change the layout of your application. For your "Hello World!" application, this file will have following content related to default layout −

    
    
       
    
    
    

提交回复
热议问题