2012-07-02 42 views
8

sau mã không làm việc cho Jelly Bean (Android 4.1):Android - menu cài đặt mạng di động (Jelly Bean)

final ComponentName cn = new ComponentName("com.android.phone","com.android.phone.Settings"); 
final Intent intent=new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS); 
intent.addCategory(Intent.CATEGORY_LAUNCHER); 
intent.setComponent(cn); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(intent); 

Thay vào đó để bắt đầu cài đặt, nó doesn't gì, bất kỳ ý tưởng làm thế nào để giải quyết nó ?

Dưới đây là giải pháp:

final ComponentName cn = new ComponentName("com.android.phone","com.android.phone.MobileNetworkSettings"); 
final Intent intent = new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS); 
intent.addCategory(Intent.ACTION_MAIN); 
intent.setComponent(cn); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(intent); 

Cảm ơn các bạn:)

+0

thử sau khi thêm FLAG_A CTIVITY_NEW_TASK cờ –

Trả lời

5

thử như:

final Intent intent=new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS); 
intent.addCategory(Intent.CATEGORY_LAUNCHER); 
final ComponentName cn = new ComponentName("com.android.phone","com.android.phone.Settings"); 
intent.setComponent(cn); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(intent); 
+0

nếu điều này không hoạt động thì cách dễ dàng gắn thiết bị của bạn vào trình gỡ rối và khởi chạy cài đặt ACTION_DATA_ROAMING_SETTINGS theo cách thủ công rồi xem trong nhật ký tên gói và Tên hoạt động được khởi động bằng hệ thống –

+0

kiểm tra tên hoạt động trong nhật ký sonething như com.android.phone/.Settings? ? –

0

Đoạn code dưới đây là đơn giản hơn nhiều và thử nghiệm trên Gingerbread (2.3.7) và JB (4.1.2)

startActivityForResult(new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS), 0); 
Các vấn đề liên quan