DeepLink / IntentScheme



package My_Package_Name;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

public class FirstActivity extends AppCompatActivity {
    TextView FIRST;
    Intent I;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first_activity);
        FIRST = (TextView)findViewById(R.id.FIRST);
        I = getIntent();
        String A = I.getStringExtra("firstParam");
        if(A==null){
            FIRST.setText("FIRST SCREEN");
        }else{
            Toast.makeText(this, A, Toast.LENGTH_SHORT).show();
            FIRST.setText(A);
        }
    }
}

package My_Package_Name;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import android.widget.Toast;

public class SecondActivity extends AppCompatActivity {
    TextView SECOND;
    Intent I;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second_activity);
        SECOND = (TextView)findViewById(R.id.SECOND);
        I = getIntent();
        String A = I.getStringExtra("secondParam");
        if(A==null){
            SECOND.setText("SECOND SCREEN");
        }else{
            Toast.makeText(this, A, Toast.LENGTH_SHORT).show();
            SECOND.setText(A);
        }
    }
}

<activity    android:name=".FirstActivity"    android:label="@string/first" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:host="*" android:scheme="firstscheme" />

    </intent-filter>
</activity>


<activity    android:name=".SecondActivity"    android:label="@string/second" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:host="*" android:scheme="secondscheme" />
    </intent-filter>
</activity>

<div class="diving">
    <input class="putting" placeholder="Package_Name" type="text" id="packOne"><br>
    <input class="putting" placeholder="Scheme_Name" type="text" id="schemeOne"><br><br>

    <input class="putting" placeholder="Enviar String para primeira Atividade" type="text" id="FirstOne"><br>
    <input type="submit" onclick="FirstActivity(packOne.value, schemeOne.value, FirstOne.value)" value="Enviar String para primeira Atividade"><br><br>

    <input class="putting" placeholder="Enviar String para segunda Atividade" type="text" id="SecondOne"><br>
    <input type="submit" onclick="SecondActivity(packOne.value, schemeOne.value,SecondOne.value)" value="Enviar String para segunda Atividade">
</div>


<script>
   function FirstActivity(value) {
  var FirstPKG = document.getElementById('packOne').value;
  var FirstS = document.getElementById('schemeOne').value;
  var FirstActivity = document.getElementById('FirstOne').value;
  if(FirstActivity.length == 0){alert('NULO');}else{
     document.location.href = "intent://scan/#Intent;scheme="+FirstS+";package="+FirstPKG+";S.firstParam="+FirstActivity+";S.browser_fallback_url=https://play.google.com/store/apps/details?id="+FirstPKG+";end";
  alert("Se tudo foi configurado corretamente este valor : [ "+FirstActivity+" ] será enviado para o pacote : [ "+FirstPKG+" ] com o valor desta scheme : [ "+FirstS+" ]");
      }
  }

   function SecondActivity(value) {
  var FirstPKG = document.getElementById('packOne').value;
  var FirstS = document.getElementById('schemeOne').value;
  var SecondActivity = document.getElementById('SecondOne').value;
  if(SecondActivity.length == 0){alert('NULO');}else{
     document.location.href = "intent://scan/#Intent;scheme="+FirstS+";package="+FirstPKG+";S.secondParam="+SecondActivity+";S.browser_fallback_url=https://play.google.com/store/apps/details?id="+FirstPKG+";end";
  alert("Se tudo foi configurado corretamente este valor : [ "+SecondActivity+" ] será enviado para o pacote : [ "+FirstPKG+" ] com o valor desta scheme : [ "+FirstS+" ]");
      }
}
</script>








Nenhum comentário:

Postar um comentário

Obrigado por comentar, volte sempre!

Seguidores

Pages




Ajude continuar nossos projetos.    

Copie este código: [[address]]

Donation of [[value]] BTC Received. Thank You.
[[error]]






Copiado