Saturday 10 October 2015

Push button secret code help



I am have been working on this app for a few weeks now. I have never done any coding in my life, until I started this app. I have a few secret codes/dial codes that I use often, but i forget what code to use when sometimes, so I wanted to make an app that would make it as simple as clicking a button, and the app would send the code for me.
I have all my buttons, and I have them programmed. I gave the permissions that I think it needs, but when I run the app on my phone I get nothing. In Android Studio, I can read this,
"W/BroadcastQueue: Permission Denial: broadcasting Intent { act=android.provider.Telephony.SECRET_CODE dat=android_secret_code://XXXXXX flg=0x10 } from com.myapp.appname (pid=7540, uid=10128) requires android.permission.CONTROL_INCALL_EXPERIENCE due to receiver com.google.android.apps.tycho/.receivers.DialerCodeReceiver"
for permissions I have:
AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.CONTROL_INCALL_EX PERIENCE" />
MainActivity.java:
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button)findViewById(R.id.Button);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String secretCode1 = "xxxxx";
String action = "android.provider.Telephony.SECRET_CODE";
Uri uri = Uri.parse("android_secret_code://" + xxxxx);
Intent button1 = new Intent(action, uri);
sendBroadcast(button1);
}
});
Activity_main.xml - Textview
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button"
android:id="@+id/Button"
android:layout_gravity="center_horizontal"
android:onClick="onbuttonclick" />

Please, let me know what I did wrong, or if you need more information to fix it.



No comments:

Post a Comment