I have a pixel 7 with Mep enabled and i am trying to read this data in my app.
I have a physical Sim in a Work profile and an eSim in a Personal profile.
I tried the below code in my MainActivity's onCreate:
val smanager = getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager
Log.i("SUBS_TEST", "count -> ${smanager.activeSubscriptionInfoCount}")
smanager.activeSubscriptionInfoList.forEach {
Log.i("SUBS_TEST", "mep -> ${it.displayName}")
}
But the output of the count is always returning 0
Can someone help me on how to get the profiles ?
Related
I am testing how to store game data using Godot 3.2.2 (I also tested Godot 3.2.3-rc4). When I exported the project (basicly you press a button and 1 is added to the score, which is displayed by a label) on Windows everything worked fine, the score was saved. But when I exported it to my Android phone the data was not saved. In the export setting I have enabled all permissions and in the settings of my phone I enabled the storage permission to my app. Maybe anybody of you can explain this to me and tell me how to solve this problem, so that data is also stored on android.
Code:
extends Node2D
var score = 0
var path = "user://save_file.json"
var save_game_data
func _ready() -> void:
load_data()
set_label_text()
func _on_Button_pressed() -> void:
score += 1
set_label_text()
func set_label_text():
$Label.text = str(score)
func _notification(what: int) -> void:
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
save_game_data = {
"score": score
}
save_data()
func save_data():
var save_game = File.new()
save_game.open(path, File.WRITE)
save_game.store_line(to_json(save_game_data))
save_game.close()
func load_data():
var save_game = File.new()
if not save_game.file_exists(path):
print("No save file found")
save_data()
return
save_game.open(path, File.READ)
save_game_data = parse_json(save_game.get_line())
score = save_game_data["score"]
print("Saved game loaded", save_game_data)
According to the docs on NOTIFICATION_WM_QUIT_REQUEST:
Implemented on desktop platforms.
NOTIFICATION_WM_QUIT_REQUEST is mainly so you can implement an "Are you sure you want to quit?" dialog, or similar. Mobile platforms generally don't have this option--when you press the home button, the window closes whether it wants to or not.
You could solve this by autosaving whenever the score changes (or at the end of a round, etc).
I want to take audio input in my unity application which I am building for Android platform. The code I have added in Start Function is as follows:
var audio = GetComponent< AudioSource > ();
audio.clip = Microphone.Start("Built-in Microphone", true, 10, 44100);
audio.loop = true;
while (!(Microphone.GetPosition(null) > 0)) { }
audio.Play();
But it is showing the following error:
ArgumentException: Couldn't acquire device ID for device name Built-in Microphone
I'm referring from this post to add microphone. How to resolve this? Also, is there any blog available for doing this end to end?
The error message clearly indicates that it can't find a Microphone device named "Built-in Microphone". So you should probably see what devices it can find.
Try running the following code in the Start method and see what output you get:
foreach (var device in Microphone.devices)
{
Debug.Log("Name: " + device);
}
Once you have a list of the devices, then replace "Built-in Microphone" with the name of your desired device. If "Built-in Microphone" is in the list or you get the same issue with a different device, then you're probably dealing with a permissions issue.
anyone know - its possible to get
"PIN CODE"
"PIN2 CODE"
"PUK1 CODE"
"PUK2 CODE"
from sim card??
im using this code for getting other info like : sim number, sim operator, sim serial.
List<SubscriptionInfo> subscriptionInfos = SubscriptionManager.from(context).getActiveSubscriptionInfoList();
for(int i=0; i<subscriptionInfos.size();i++)
{
SubscriptionInfo subInfo = subscriptionInfos.get(i);
}
but how about pin/puk codes? I need get it programmaticaly without "special number call"
I was trying to get the MCC and MNC number (basically I want the IMSI number but these will also suffice) in Android 5.1 device having dual Sim (both active). As 5.1 supports dual Sim so I used the Subscription manager like this:
SubscriptionManager manager = SubscriptionManager.from(this);
List<SubscriptionInfo> sil = manager.getActiveSubscriptionInfoList();
if (sil != null) {
for (SubscriptionInfo subInfo : sil) {
Log.v("TestMain", "SubInfo:" + subInfo);
}
} else {
Log.v("TestMain", "SubInfo: list is null");
}
and got the this output:
07-24 18:28:32.162 3844-3844/? V/TestMain﹕ SubInfo:{id=1, mcc 405 mnc 803, iccId=89918030914128062059 simSlotIndex=0 displayName=Aircel Karnataka carrierName=Aircel — Aircel Karnataka nameSource=0}
07-24 18:28:32.162 3844-3844/? V/TestMain﹕ SubInfo:{id=2, mcc 405 mnc 803, iccId=8991860044481968955 simSlotIndex=1 displayName=CARD 2 carrierName=Vodafone Karnataka nameSource=0}
MCC(will be same as it the same country)
notice that MNC are same though the carriers are different.
While I was switching off the phone I saw this lines in my logcat:
07-24 18:31:02.295 616-616/? V/KeyguardUpdateMonitor﹕ SubInfo:{id=1, mcc 405 mnc 803, iccId=89918030914128062059 simSlotIndex=0 displayName=CARD 1 carrierName=Emergency calls only — Aircel Karnataka nameSource=0}
07-24 18:31:02.295 616-616/? V/KeyguardUpdateMonitor﹕ SubInfo:{id=2, mcc 404 mnc 86, iccId=8991860044481968955 simSlotIndex=1 displayName=CARD 2 carrierName=Emergency calls only — Vodafone Karnataka nameSource=0}
As you can see the keyguard application gets the MNC right for both the sim.
So I explored the code of the keyguard application and found that the code is same as I was using
Code from Android Source taken from here:
protected void handleSimSubscriptionInfoChanged() {
if (DEBUG_SIM_STATES) {
Log.v(TAG, "onSubscriptionInfoChanged()");
List<SubscriptionInfo> sil = mSubscriptionManager.getActiveSubscriptionInfoList();
if (sil != null) {
for (SubscriptionInfo subInfo : sil) {
Log.v(TAG, "SubInfo:" + subInfo);
}
} else {
Log.v(TAG, "onSubscriptionInfoChanged: list is null");
}
}
I explored some more and found that even the keyguard applications gets MCC right only when the phone is switching off, other times even it is getting the same MNC for both the SIMs. But the carrier name is distinct always.
Is this a bug in Android 5.1 or am I doing something wrong?
I got the same issue in Android 5.1 in Samsung J5, but its working in Android 6.0 in Moto X Play. Since SubscriptionManager was introduced in Android 5.1, I guess this is a bug in Android 5.1, which was corrected in Android M.
This was a bug in android 5.1, it got fixed after I updated the phone
I have written code for adding open network to wifi configured list.It adds the open network to configured lists and displays the same SSID's in Wifi Settings.but it adds the same network with same name extra but it doesn't shows any open network When i press on the second on alert shows with Security WEP the following text i observed with those same networks
1) Open network
2) remembered , not in range
But i want to add open network into my list, why this extra one is added and if i connect the same network it is trying to connect to the (2) one programmatically.Actually I changed secured network to open network for this trial.It displays with open network text and when i press on that one it obtains the address and connects succesfully manually.Why this extra one is adding how can i add the open network to my list.For reference plz see the link for image.
http://www.freeimagehosting.net/uploads/3dbccfc2bd.png
Code snippet :
String hotSpotSsid = hotSpot.SSID;
String hotSpotBssid = hotSpot.BSSID;
Log.i(TAG,"in RSSI Changed Acion SSID: "+hotSpotSsid+" BSSID: "+hotSpotBssid);
StringBuffer sBuf = new StringBuffer("\"");
sBuf.append(hotSpotSsid+"\"");
hotSpotSsid = sBuf.toString();
WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.SSID = hotSpotSsid;
wifiConfiguration.allowedKeyManagement.set(KeyMgmt.NONE);
wifiConfiguration.BSSID = hotSpotBssid;
wifiConfiguration.hiddenSSID = false;
// wifiConfiguration.priority = 1;
// add this to the configured networks
int inetId = wifiManager.addNetwork(wifiConfiguration);
Log.i(TAG,"INetId :"+inetId);
configs = wifiManager.getConfiguredNetworks();
Log.e(TAG,"After adding config :"+configs);
if(inetId < 0) {
Log.i(TAG,"Unable to add network configuration for SSID: "+hotSpotSsid);
return;
}else {
message="\t Successfully added to configured Networks";
Log.i(TAG,message);
}
regards,
Rajendar
Try removing SSID and seeing if it works. I was having a similar issue and that worked for me.
Appending and prepending quotes to the SSID, as you did, should work though. Not sure why it doesn't.
Give SSID as wifiConfiguration.SSID = "\"".concat(SSID_NAME).concat("\"");