• Не работает получение SMS?

    @osinvladislav Автор вопроса
    GavriKos, вот код
    activity_main:
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:context=".MainActivity"
        tools:showIn="@layout/app_bar_main">
    
         <TextView
            android:id="@+id/welcome"
            android:layout_width="wrap_content"
            android:layout_height="29dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="68dp"
            android:text="@string/main"
            android:textAppearance="@style/TextAppearance.AppCompat.Large"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_chainStyle="spread_inside" />
    
        <TextView
            android:id="@+id/address"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="112dp"
            android:text="Номер телефона:"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
        <TextView
            android:id="@+id/message"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="144dp"
            android:text="Сообщение:"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </android.support.constraint.ConstraintLayout>

    и activity_manage:
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:context=".ManageActivity"
        tools:layout_editor_absoluteY="81dp"
        tools:showIn="@layout/app_bar_main_manage">
    
        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="29dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:text="@string/manage"
            android:textAppearance="@style/TextAppearance.AppCompat.Large"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_chainStyle="spread_inside" />
    
        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_marginEnd="64dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="52dp"
            android:text="@string/enter_number"
            android:textAppearance="@android:style/TextAppearance"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
        <EditText
            android:id="@+id/save_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="68dp"
            android:ems="10"
            android:inputType="phone"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="136dp"
            android:onClick="saveText"
            android:text="@string/save"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
        <TextView
            android:id="@+id/open_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_marginTop="112dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.065"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
    </android.support.constraint.ConstraintLayout>
  • Не работает получение SMS?

    @osinvladislav Автор вопроса
    GavriKos, Пермишен есть, приложение доступ получает. при заходе в приложение человек видит пустую страницу, когда в настройках выставляется номер, человек видит Адрес: и Текст сообщения: без самих значений
  • Не работает получение SMS?

    @osinvladislav Автор вопроса
    ManageActivity:
    package ru.apiscale.apiscale;
    
    import android.content.Context;
    import android.content.Intent;
    import android.content.SharedPreferences;
    import android.os.Bundle;
    import android.support.design.widget.FloatingActionButton;
    import android.support.design.widget.Snackbar;
    import android.view.View;
    import android.support.design.widget.NavigationView;
    import android.support.v4.view.GravityCompat;
    import android.support.v4.widget.DrawerLayout;
    import android.support.v7.app.ActionBarDrawerToggle;
    import android.support.v7.app.AppCompatActivity;
    import android.support.v7.widget.Toolbar;
    import android.view.Menu;
    import android.view.MenuItem;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;
    
    public class ManageActivity extends AppCompatActivity
            implements NavigationView.OnNavigationItemSelectedListener {
        SharedPreferences mSettings;
        public static final String APP_PREFERENCES = "mysettings";
        public static final String APP_PREFERENCES_NAME = "phone_number";
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_manage);
            Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
            setSupportActionBar(toolbar);
    
            FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
            fab.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Snackbar.make(view, "19.07.2018 04:19:55", Snackbar.LENGTH_LONG)
                            .setAction("Action", null).show();
                }
            });
    
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                    this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
            drawer.addDrawerListener(toggle);
            toggle.syncState();
    
            NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
            navigationView.setNavigationItemSelectedListener(this);
            //TextView textView = (TextView) findViewById(R.id.open_text);
            //textView.setText(R.string.number_now + R.string.unknown);
    
        }
    
        @Override
        public void onBackPressed() {
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            if (drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.closeDrawer(GravityCompat.START);
            } else {
                super.onBackPressed();
            }
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // Handle action bar item clicks here. The action bar will
            // automatically handle clicks on the Home/Up button, so long
            // as you specify a parent activity in AndroidManifest.xml.
            int id = item.getItemId();
    
            //noinspection SimplifiableIfStatement
            if (id == R.id.action_coin) {
                Intent intent = new Intent(ManageActivity.this, CoinActivity.class);
                startActivity(intent);
                return true;
            }
            if (id == R.id.action_about) {
                Intent intent = new Intent(ManageActivity.this, AboutActivity.class);
                startActivity(intent);
                return true;
            }
            if (id == R.id.action_developers) {
                Intent intent = new Intent(ManageActivity.this, DevelopersActivity.class);
                startActivity(intent);
                return true;
            }
    
            return super.onOptionsItemSelected(item);
        }
    
        @SuppressWarnings("StatementWithEmptyBody")
        @Override
        public boolean onNavigationItemSelected(MenuItem item) {
            // Handle navigation view item clicks here.
            int id = item.getItemId();
    
            if (id == R.id.nav_main) {
                Intent intent = new Intent(ManageActivity.this, MainActivity.class);
                startActivity(intent);
            } else if (id == R.id.nav_graphic) {
                Intent intent = new Intent(ManageActivity.this, GraphicActivity.class);
                startActivity(intent);
            } else if (id == R.id.nav_manage) {
                Intent intent = new Intent(ManageActivity.this, ManageActivity.class);
                startActivity(intent);
            } else if (id == R.id.nav_send) {
                Intent intent = new Intent(ManageActivity.this, SendActivity.class);
                startActivity(intent);
    
            }
    
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            drawer.closeDrawer(GravityCompat.START);
            return true;
        }
        public void onClick(View v) {
            mSettings = getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);
            EditText number = (EditText)findViewById(R.id.save_text);
            String phone_number = number.getText().toString();
            SharedPreferences.Editor editor = mSettings.edit();
            editor.putString(APP_PREFERENCES_NAME, phone_number);
            editor.apply();
        }
    }