Android en una simple Activity (Edittext, imagen) no se muestran los datos

soy muy nuevo en Android y seguramente éste es un error muy básico. Desde el menú inicio una actividad muy básica, obtener el nombre y la imagen del usuario. Los datos son guardados en room sqlite sin problema, cuando llamo nuevamente a la actividad aparece vacia. Al correr en modo Debug puedo ver que los datos son leidos de la DB y cuando llego a la llave que cierra onCreate los datos están cargados en las variables, pero al pulsar F7 nuevamente el Layout aparece vacio. Si lo ejecuto paso a paso, algunas veces aparece el nombre y la imagen antes que termine de llegar al final. Los datos están pero no sé como hacer que aparezcan. Desde ya agradezco cualquier ayuda que me puedan dar.

Layout

<?xml version="1.0" encoding="utf-8"?> 

android:id="@+id/edtcontrol" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".activity.mysetting">  <com.app.pajaritum.utility.RoundRectCornerImageView     android:id="@+id/imguser"     android:layout_width="193dp"     android:layout_height="285dp"     android:layout_centerInParent="true"     android:key="img"     android:src="@drawable/placeholder" />  <EditText      android:id="@+id/edittext_name"     android:layout_width="280dp"     android:layout_height="wrap_content"     android:layout_centerHorizontal="true"     android:layout_marginTop="16dp"     android:hint="Name"     android:inputType="textCapWords"     android:textAppearance="?android:attr/textAppearanceMedium" />    <Button     android:id="@+id/submit"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignParentBottom="true"     android:layout_centerHorizontal="true"     android:text="Submit" /> 

Code.java

    @Override public void onCreate(@Nullable Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.mysetting);      submit = (Button) findViewById(R.id.submit);     edttextname = (EditText) findViewById(R.id.edittext_name);      img_user = (RoundRectCornerImageView) findViewById(R.id.imguser);      setVdata();      submit.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View v) {             addvnow();             Toast.makeText(mysetting.this, "Saved", Toast.LENGTH_SHORT).show();         }     });      img_user.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View v) {              selectimguser = true;             EasyImage.openChooserWithDocuments(mysetting.this,                     "Choose Your Image", 0);         }     });  }   @Override     public void onActivityResult ( int requestCode, int resultCode, Intent data){         super.onActivityResult(requestCode, resultCode, data);          EasyImage.handleActivityResult(requestCode, resultCode, data, mysetting.this, new DefaultCallback() {              @Override             public void onImagesPicked(List<File> imagesFiles, EasyImage.ImageSource source, int type) {                 //Handle the images                 if (selectimgvet) {                     imguser = imagesFiles.get(0);                     displaySelectedImage2(false);                      img_user.setFocusable(true);                 }             }              @Override             public void onImagePickerError(Exception e, EasyImage.ImageSource source, int type) {                 //Some error handling             }         });     }  private void displaySelectedImage2(boolean compress) {     try {          Bitmap myBitmap = BitmapFactory.decodeFile(imgvet.getAbsolutePath());         if (compress) {             myBitmap = CompressAndSaveImage.ScaledPhotoBitmapToFile(myBitmap, new ByteArrayOutputStream());         }         if (myBitmap == null) {             img_user.setImageResource(R.drawable.placeholder);          } else {             img_user.setImageBitmap(myBitmap);         }      } catch (Exception e) {         img_user.setImageResource(R.drawable.placeholder);      }  }   public void setVdata() {     new AsyncTask<Void, Void, List<VetdataModel>>() {         @Override         protected List<VetdataModel> doInBackground(Void... voids) {             try {                 vetdataModel = AppDatabase.getInstance(mysetting.this).vetdataDao().loadset();               } catch (Exception e) {             }             return null;          }     }.execute();      if (vetdataModel == null) {            // mysetting.this.finish();         return;     }      edttextname.setText(vetdataModel.getname());      try {         System.out.println("IMAGE2ES: " + vetdataModel.getImguser().length);         if (vetdataModel.getImguser().length > 0) {             imguser = Methods.byteArrayToFile(mysetting.this, vetdataModel.getImguser(), "2");          } else {             imguser = null;         }         System.out.println("IMAGE2ES@: " + imguser);     } catch (Exception e) {     }     displaySelectedImage2(false);      } 

button abrindo uma nova activity problema em uma class

package com.ftc;  import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button;  public class MainActivity extends AppCompatActivity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         Button btnTela2 = (Button) findViewById(R.id.btnTela2);         btnTela2.setOnClickListener(this);     }     public void onClick(View v){         Intent it = new Intent(this, Menu.class);         startActivity(it);     } } 

btnTela2.setOnClickListener(this); está aparecendo esse error inserir a descrição da imagem aqui

How to execute an equivalent function of Xcode’s Instruments > “File Activity” in shell?

I need to be able to show and capture the same output that Xcode.app/Contents/Applications/Instruments.app captures while in Terminal.app (in the shell). Is there a dtrace function / script, or some such equivalent, that can be run in order to capture this data directly?

Using fail2ban for detecting suspicious activity whitin a webserver

I know that fail2ban is mostly used for blocking IPs trying to brute force an SSH endpoint and other stuff like that.

However, I am wondering if you could also use fail2ban to detect (not necessarily prevent) suspicious activity within a webserver.

For example: Let’s say an attacker managed to break into a webserver as a non-privileged account (by whatever means: be it a Remote Code Execution flaw in the web application, brute-forcing a password or even a vulnerability in the Operating System). The attacker is now able to run commands on that machine. One of the things an attacker might now try to do is to somehow conduct a privilege escalation attack to gain root access. I guess that most attacks like that and other activities and intruder will normally do within a webserver would cause some traces within the log files – which could be monitored and admins could be warned via email or something like that.

If this is the case: Does it make sense to use fail2ban for this task?

If yes: How do you do that? Which log files should be watches for what kind of regex? Are there ready-to-use fail2ban jails for that somewhere on the web? (Couldn’t find any.)

The webserver I’m talking about is of “midlevel importance” I’d say and runs with Ubuntu 18.04.

(I know there are many tools or Intrusion Detection Systems better suitable for that task. However, using fail2ban would have some advantages in my case.)

Переход между Activity вылетает приложение

import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button;  public class MainActivity extends Activity {  @Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_main);       final Button ok = findViewById(R.id.ok);     ok.setText("OK");      ok.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View view) {             Intent intent = new Intent("second");             startActivity(intent);         }     });  } 

}

вот мой код, никак не могу понять, почему при нажатии на кнопку оно сразу же выдает ошибку и закрывается?

Class Activity Calculator


Introduction

Class Activity Calculator is an online application to calculate the students’ class activity grades. The class activity grade (CA) is calculated based on the marks a student gets during the term. Here’s a sample grade sheet we use in class:

enter image description here

Please review the code and provide feedback.

Source

<!DOCTYPE html> <html lang="en">  <head>   <meta charset="UTF-8">   <meta name="viewport" content="width=device-width, initial-scale=1">   <meta name="description" content="Calculate the class activity grades of the ILI students.">   <title>Class Activity Calculator</title>   <link rel="icon" href="favicon.ico">   <link rel="stylesheet" href="style.css"> </head>  <body>   <header>     <img src="logo.png" alt="Logo">     <h1>Class Activity Calculator</h1>   </header>   <nav>     <a href="index.html" id="current">Adults: Old</a>     <a href="adults-new.html">Adults: New</a>     <a href="young-adults.html">Young Adults</a>     <a href="kids.html">Kids</a>   </nav>   <main>     <form autocomplete="off">       <fieldset data-weight="4">         <legend>Listening & Speaking</legend>         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <output></output>       </fieldset>       <fieldset data-weight="3">         <legend>Reading</legend>         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <output></output>       </fieldset>       <fieldset data-weight="1">         <legend>Writing</legend>         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <input type="number" step="any" min="0" max="100">         <output></output>       </fieldset>       <div>         <button type="button">Calculate</button>         <output></output>         <button type="reset">Reset</button>       </div>     </form>   </main>   <footer>     Share on <a href="https://t.me/share/url?url=https%3A%2F%2Fclassactivitycalculator.github.io%2F&text=Class%20Activity%20Calculator%3A%20Calculate%20the%20class%20activity%20grades%20of%20the%20ILI%20students." title="Telegram: Share Web Page">Telegram</a> |     <a href="https://www.facebook.com/dialog/share?app_id=2194746457255787&href=https%3A%2F%2Fclassactivitycalculator.github.io%2F" title="Post to Facebook">Facebook</a>     <address><a href="https://t.me/MortezaMirmojarabian" title="Telegram: Contact @MortezaMirmojarabian" rel="author">Give feedback</a></address>   </footer>   <script>     function setOutputValues() {       var totalWeightedAverage = 0;       var totalWeight = 0;       var fieldsets = form.querySelectorAll('fieldset');       for (var fieldset of fieldsets) {         var average = averageInputValues(fieldset);         var fieldsetOutput = fieldset.querySelector('output');         if (average == undefined) {           fieldsetOutput.value = 'You may only enter 0 to 100.';         } else if (isNaN(average)) {           fieldsetOutput.value = 'Please enter a grade.';         } else {           fieldsetOutput.value = 'avg: ' + average.toFixed(1);         }         totalWeightedAverage += average * fieldset.dataset.weight;         totalWeight += Number(fieldset.dataset.weight);       }       var classActivity = totalWeightedAverage / totalWeight;       var divOutput = form.querySelector('div output');       if (isNaN(classActivity)) {         divOutput.value = '';       } else {         divOutput.value = 'CA: ' + classActivity.toFixed(1);       }     }   </script>   <script src="global.js"></script> </body>  </html> 

style.css

html, body {   margin: 0;   padding: 0; }  header {   padding: 16px 0;   text-align: center;   background: linear-gradient(#999, #333); }  img {   width: 36px;   height: 36px;   vertical-align: bottom; }  h1 {   font-size: 1.125rem;   font-family: 'Times New Roman';   color: #FFF;   text-shadow: 0 3px #000;   letter-spacing: 1px; }  nav {   display: flex;   justify-content: center;   background: #333;   border-top: 2px solid; }  a {   color: #FFF; }  nav a {   padding: 12px 6px;   font: bold 0.75rem Verdana;   text-decoration: none; }  nav a:not(:last-child) {   margin-right: 2px; }  nav a:hover, nav a:focus, #current {   outline: 0;   border-top: 2px solid;   margin-top: -2px; }  main, div {   display: flex; }  form {   margin: 32px auto; }  fieldset {   margin: 0 0 16px;   padding: 12px 12px 0;   border: 1px solid #CCC;   background: linear-gradient(#FFF, #CCC); }  legend, input, output, button {   font-family: Arial; }  legend, button {   color: #333; }  legend {   padding: 0 4px;   font-size: 0.875rem; }  input, button, div output {   font-size: 0.833rem; }  input {   width: 4em; }  input:invalid {   outline: 1px solid red; }  output {   color: #C00; }  fieldset output {   display: block;   margin: 8px 0 8px 6px;   font-size: 0.75rem; }  fieldset output::after {   content: "A0"; } /* a placeholder */  div output {   margin: auto auto auto 6px; }  footer {   padding: 12px;   background: #333;   font: 0.75rem Arial;   color: #FFF; }  address {   float: right; } 

global.js

var form = document.querySelector('form');  function averageInputValues(fieldset) {   var totalValue = 0;   var totalNumber = 0;   var inputs = fieldset.querySelectorAll('input');   for (var input of inputs) {     if (!input.validity.valid) {       return;     }     totalValue += Number(input.value);     totalNumber += Boolean(input.value);   }   return totalValue / totalNumber; }  form.querySelector('[type="button"]').addEventListener('click', setOutputValues);  function detectChange() {   var inputs = form.querySelectorAll('input');   for (var input of inputs) {     if (input.value) {       return true;     }   } }  form.querySelector('[type="reset"]').addEventListener('click', function(event) {   if (detectChange() && !confirm('Your changes will be lost.\nAre you sure you want to reset?')) {     event.preventDefault();   } });  window.addEventListener('beforeunload', function(event) {   if (detectChange()) {     event.returnValue = 'Your changes may be lost.';   } }); 

Как в одном Activity отображать разные Fragment

Допустим у меня есть несколько кнопок в Activity: btn1,btn2 ,btn3,btn4. Как сделать что бы например, при нажатии на btn1 открывалось Activity2 с Fragment 1 , при нажатии на btn2 , тоже открывалось Activity2 с Fragment 1 и Fragment 2, и тд

Como pasar datos entre dos Activity y posteriormente a Fragments

soy nuevo programando con android y mucho le sabré agradecer si me podrían ayudar a completar esta tarea.

Cuento con una actividad A que muestra una lista de datos a través de un RecyclerView y un CardView (Datos obtenidos desde SqlServer). Todo funciona bien hasta acá, la idea es cargar el detalle de los datos en una actividad B (Tabbed Activity) que posteriormente los muestre en dos fragments. Hasta ahora he podido llevar los datos desde la actividad A hasta la actividad B, pero no logro enlazar un TextView con el dato obtenido. alguna sugerencia? De antemano, gracias!

MOSTRANDO LOS DATOS EN EL CARD (ACTIVITY A) Y POSTERIORMENTE ENVIÁNDOLOS AL TAB (ACTIVITY B):

public class  ListArtAdapter extends RecyclerView.Adapter<ListArtAdapter.ArtViewHolder> {  private List<Art> items;  public static class ArtViewHolder extends RecyclerView.ViewHolder{     public CardView art_cardviev;     public ImageView dis_cen;     public TextView co_art;      public ArtViewHolder(View view){         super(view);         art_cardviev = view.findViewById(R.id.art_cardview);         dis_cen = view.findViewById(R.id.dis_cen);         co_art = view.findViewById(R.id.co_art); }      // Metodo para crear el adaptador que recibe como parametro la lista de articulos     public ListArtAdapter(List<Art> items){         this.items = items;     }  @Override public int getItemCount() {     return items.size(); }  @NonNull @Override public ArtViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {     View view = LayoutInflater.from(viewGroup.getContext())             .inflate(R.layout.activity_list_art_cardview, viewGroup, false);     return new ArtViewHolder(view); }  @Override public void onBindViewHolder(@NonNull ArtViewHolder artViewHolder, final int i) {     artViewHolder.dis_cen.setImageResource(items.get(i).getDis_cen());     artViewHolder.co_art.setText(items.get(i).getCo_art());      //Asignando envento click al activity_list_art_cardview declarado al principio     artViewHolder.art_cardviev.setOnClickListener(new View.OnClickListener() {          //Pasamos los datos a la actividad TabArtActivity         @Override         public void onClick(View v) {             Bundle bundle = new Bundle();             bundle.putInt("curDis_cen", items.get(i).getDis_cen());             bundle.putString("curCo_art", items.get(i).getCo_art());              Intent intent = new Intent(v.getContext(), TabArtActivity.class);             intent.putExtras(bundle);             v.getContext().startActivity(intent);         }     }); } 

}

ADAPTADOR DEL TAB ACTIVITY

public class TabArtAdapter extends FragmentPagerAdapter {

@StringRes private static final int[] TAB_TITLES = new int[]{R.string.txt_detalles, R.string.txt_valores}; private final Context mContext;  public TabArtAdapter(Context context, FragmentManager fm) {     super(fm);     mContext = context; }  @Override public Fragment getItem(int position) {     // getItem is called to instantiate the fragment for the given page.     // Return a PlaceholderFragment (defined as a static inner class below).     //return PlaceholderFragment.newInstance(position + 1);      switch (position){         case 0:             DetailArtFragment detailArtFragment = new DetailArtFragment();             return detailArtFragment;         case 1:             AmountArtFragment amountArtFragment = new AmountArtFragment();             return amountArtFragment;     }     return null; }  @Nullable @Override public CharSequence getPageTitle(int position) {     return mContext.getResources().getString(TAB_TITLES[position]); }  @Override public int getCount() {     // Show 2 total pages.     return 2; } 

}

RECIBIENDO LOS DATOS EN EL ACTIVITY B

public class TabArtActivity extends AppCompatActivity {

@Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_tab_art);      TabArtAdapter tabArtAdapter = new TabArtAdapter(this, getSupportFragmentManager());     ViewPager viewPager = findViewById(R.id.view_pager);     viewPager.setAdapter(tabArtAdapter);      TabLayout tabs = findViewById(R.id.tabs);     tabs.setupWithViewPager(viewPager);      Bundle bundle = getIntent().getExtras();     String co_art = bundle.getString("curCo_art");      Bundle bundleDetail = new Bundle();     bundleDetail.putString("curCo_art",co_art);      DetailArtFragment detailArtFragment = new DetailArtFragment();     detailArtFragment.setArguments(bundleDetail);      Toast.makeText(getApplicationContext(), "Prueba" + co_art, Toast.LENGTH_SHORT).show(); } 

}

FRAGMENTO QUE MUESTRA LA INFORMACION OBTENIDA EN EL ACTIVITY B

public class DetailArtFragment extends Fragment {

TextView co_art;  @Override public void onCreate(@Nullable Bundle savedInstanceState) {     super.onCreate(savedInstanceState);  }  @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,                          Bundle savedInstanceState) {     // Inflate the layout for this fragment     View v = inflater.inflate(R.layout.fragment_detail_art, container, false);     co_art = v.findViewById(R.id.co_art);     //co_art.setText(getArguments().getString("curCo_art"));      String codigo = this.getArguments().getString("curCo_art").toString();     co_art.setText(codigo);      return v; } 

}

Can NSF Broader Impact be an unrelated volunteer activity?

I’m a grad student preparing to apply for an NSF fellowship and I volunteer a few hours a week working on what I think is a pretty important cause. It has nothing to do with my research or science education (although it is supported by data analytics, though I’m not directly involved in that part). Does it seem feasible to present this work as my Broader Impact?